void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (GameManager.isInMainMenuScene)
            {
                return;
            }

            string sceneName = scene.name;

            string sceneKey = SceneKey(sceneName, objectKey);

            bool sceneHasInfoForSaveObjects = SaveLoad.gameSaveState.SaveStateContainsKey(sceneKey);

            // get all the active objects that are default in the current scene
            List <C> activeObjects = SaveObject.FilterSaveObjectsForScene(sceneName, GetAllActiveDefaultObjectsInSceneLoad(sceneName));

            for (int i = 0; i < activeObjects.Count; i++)
            {
                activeObjects[i].AddInstanceToPool(sceneHasInfoForSaveObjects && activeObjects[i].IsAvailable());
            }

            // if this scene has saved info for the objects, then load the objects
            if (sceneHasInfoForSaveObjects)
            {
                // laod the scene objects states that were saved for this scene
                List <S> savedObjects = (List <S>)SaveLoad.gameSaveState.LoadSaveStateObject(sceneKey);

                for (int i = 0; i < savedObjects.Count; i++)
                {
                    C loadedObject = PrefabPool().GetAvailable(PrefabReferences.GetPrefabReference <C>(savedObjects[i].prefabObjectName, savedObjects[i].prefabName), null);

                    SaveObject.OnObjectLoad(loadedObject, loadedObject as ISaveObject <S>, savedObjects[i]);
                }
            }
        }
Example #2
0
        public static GameObject GetPrefabReference(string referencesObjectName, string prefabName)
        {
            PrefabReferences referencesObject = GameSettings.GetSettings <PrefabReferences>(referencesObjectName);

            if (referencesObject != null)
            {
                return(referencesObject.GetPrefabReference(prefabName));
            }
            return(null);
        }
Example #3
0
        public static T GetPrefabReference <T> (string referencesObjectName, string prefabName) where T : Component
        {
            PrefabReferences referencesObject = GameSettings.GetSettings <PrefabReferences>(referencesObjectName);

            if (referencesObject != null)
            {
                return(referencesObject.GetPrefabReference <T>(prefabName));
            }
            return(null);
        }