dronkowitz

MainMenu.cs

Jun 23rd, 2021 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class MainMenu : MonoBehaviour
  7. {
  8.     public int backmenu;
  9.  
  10.     public void LoadScene(int sceneIndex)
  11.     {
  12.         SceneManager.LoadScene(sceneIndex);
  13.     }
  14.  
  15.    
  16.  
  17.     public void Exit()
  18.     {
  19.         Application.Quit();
  20.     }
  21.  
  22.     protected virtual void Update()
  23.     {
  24.         if (Input.GetKeyDown(KeyCode.Escape) && SceneManager.GetActiveScene().buildIndex !=backmenu) LoadScene(backmenu);
  25.     }
  26. }
  27.  
Add Comment
Please, Sign In to add comment