void Awake() { m_Instance = this; //Check if instance already exists //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 gamaManager. if (m_Instance == null) { m_Instance = this; } else if (m_Instance != this) { Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); gamaManager = gameObject; MainCamera = GameObject.Find(IGamaManager.GAMA_MAIN_CAMERA); /* * // Create the plane game Object * plane = GameObject.CreatePrimitive(PrimitiveType.Plane); * plane.transform.localScale = new Vector3(20, 1, 20); * plane.GetComponent<Renderer>().material = planeMaterial; */ // Create the Topic's manager GameObjects new GameObject(IGamaManager.COLOR_TOPIC_MANAGER).AddComponent <ColorTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.POSITION_TOPIC_MANAGER).AddComponent <PositionTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.SET_TOPIC_MANAGER).AddComponent <SetTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.GET_TOPIC_MANAGER).AddComponent <GetTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.MONO_FREE_TOPIC_MANAGER).AddComponent <MonoFreeTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.MULTIPLE_FREE_TOPIC_MANAGER).AddComponent <MultipleFreeTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.CREATE_TOPIC_MANAGER).AddComponent <CreateTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.DESTROY_TOPIC_MANAGER).AddComponent <DestroyTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.MOVE_TOPIC_MANAGER).AddComponent <MoveTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.NOTIFICATION_TOPIC_MANAGER).AddComponent <NotificationTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.PROPERTY_TOPIC_MANAGER).AddComponent <PropertyTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.MAIN_TOPIC_MANAGER).AddComponent <MainTopic>().transform.SetParent(gamaManager.transform); new GameObject(IGamaManager.CSVREADER).AddComponent <CSVReader>().transform.SetParent(gamaManager.transform); }
void OnDestroy() { Debug.Log("----> GamaManager GameObject Destroyed"); m_Instance = null; }