void Start() { player = null; levels.Clear(); // Technically we're still loading... // LocateAndUpdateCollectablesAndInteractables(); // Populate levels foreach (AreaController level in ExtendList.FindObjectsOfTypeInactive <AreaController>()) { //levelsParent.GetComponentsInChildren<Level>(true)) { levels.Add(level); } #if UNITY_EDITOR FindPlayer(); #endif if (backgroundPlane == null) { backgroundPlane = GameObject.Find("BackgroundPlane").GetComponent <pb_Object>(); } }
void ApplySaveData(Scene scene, LoadSceneMode mode) { FindPlayer(); // Editor function as loadedFromMainMenu will never be false in production. if (LoadSaveController.loadedFromMainMenu == false) { LoadSaveController.SaveGameLocation = "saveGameTest.xml"; } if (LoadSaveController.SaveGameLocation == "") { Debug.Log("LoadSaveController.SaveGameLocation"); hasFullyLoaded = true; return; } SaveGameName = LoadSaveController.LoadedSaveName; player.transform.position = (LoadSaveController.loadedFromMainMenu == false) ? GameStartLocation.transform.position : LoadSaveController.LoadedPosition; //LoadSaveController.LoadedPosition; TotalTimePlayed = LoadSaveController.LoadedTotalTime; // Populate Collectable list. foreach (Collectable collectable in ExtendList.FindObjectsOfTypeInactive <Collectable>()) { foreach (CollectableSave savedCollectable in LoadSaveController.LoadedCollectables) { if (collectable.CollectableID == savedCollectable.CollectableID) { collectable.CollectableCollected = savedCollectable.CollectableCollected; break; } } } // Populate Interactable list. foreach (Interactable interactable in ExtendList.FindObjectsOfTypeInactive <Interactable>()) { foreach (InteractableSave savedInteractable in LoadSaveController.LoadedInteractables) { if (savedInteractable.InteractableID == interactable.InteractableID) { interactable.IsActivated = savedInteractable.IsActivated; interactable.IsDisabled = savedInteractable.IsDisabled; interactable.IsLocked = savedInteractable.IsLocked; break; } } } hasFullyLoaded = true; }