gamemanager
unknown
abc
3 years ago
1.0 kB
10
Indexable
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class GameManager : MonoBehaviour { public static GameManager sharedInstance = null; private void Awake() { if (sharedInstance != null && sharedInstance != this) { Destroy(gameObject); } else { GameObject.DontDestroyOnLoad(gameObject); sharedInstance = this; } } // Start is called before the first frame update void Start() { DontDestroyOnLoad(this.gameObject); } // Update is called once per frame void Update() { if (Input.GetKeyDown("escape")) { print("Escape key was pressed, changing scene"); LoadLevelOne(); } } public void LoadLevelOne() { Debug.Log("Loading level one"); SceneManager.LoadScene(1); } }
Editor is loading...