static void AddInitialSingletons(GameObject gameObject) { // get all types of InitializationSingleTon's and add tehm to this gameObject Type[] initSingletons = SystemTools.FindAllDerivedTypes(typeof(InitializationSingleTon <>)); for (int i = 0; i < initSingletons.Length; i++) { gameObject.AddComponent(initSingletons[i]); } }
static void BuildPlayer() { if (playerExists) { return; } // Debug.Log("Building Non Existant Player"); GameObject.Instantiate(GameManagerSettings.instance.playerPrefab); _playerCamera = player.GetComponentInChildren <Camera>(); Type[] camScripts = SystemTools.FindAllDerivedTypes(typeof(CameraScript)); for (int i = 0; i < camScripts.Length; i++) { _playerCamera.gameObject.AddComponent(camScripts[i]); } // Debug.Log("On Player Create Event"); if (onPlayerCreate != null) { onPlayerCreate(); } }
/* * start and awake should only happen during the initial scene load */ protected override void Awake() { base.Awake(); if (!thisInstanceErrored) { SceneLoading.onSceneLoadStart += OnSceneLoadStart; SaveLoad.onSaveGame += OnSaveGame; SceneManager.sceneLoaded += OnSceneLoaded; if (GameManagerSettings.instance.actionsController != null) { GameManagerSettings.instance.actionsController.InitializeActionsInterface(); } // get all types of InitializationSingleTon's Type[] results = SystemTools.FindAllDerivedTypes(typeof(InitializationSingleTon <>)); // add tehm to this gameObject for (int i = 0; i < results.Length; i++) { gameObject.AddComponent(results[i]); } } }