using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public static GameManager instance = null; /// <summary> /// PUBLIC: /// </summary> [SerializeField] List<GameObject> levelRooms; /// <summary> /// PRIVATE: /// </summary> void Awake() { //Check if instance already exists. If not, set instance to this. if (instance == null) instance = this; //If instance already exists and it's not this, then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. else if (instance != this) Destroy(gameObject); //Sets this to not be destroyed when reloading scene. DontDestroyOnLoad(gameObject); } // Use this for initialization void Start() { Object[] roomObjectList = FindObjectsOfType(typeof(RoomScript)); for (int i = 0; i < roomObjectList.Length; i++) { GameObject g = roomObjectList[i] as GameObject; levelRooms.Add(g); } } // Update is called once per frame void Update () { } }