1using System.Collections.Generic;
48 Item[] itemsInScene = GameObject.FindObjectsOfType<
Item>();
51 for(
int i = itemsInScene.Length - 1; i > -1; i--)
53 Destroy( itemsInScene[i].gameObject );
64 Item item = itemGameObject.GetComponent<
Item>();
65 item.
Init( itemCode );
74 GameObject itemGameObject;
76 foreach(
SceneItem sceneItem
in sceneItemList )
80 Item item = itemGameObject.GetComponent<
Item>();
130 if( sceneSave.m_ListSceneItem !=
null )
153 List<SceneItem> sceneItemList =
new List<SceneItem>();
154 Item[] itemsInScene = FindObjectsOfType<Item>();
157 foreach(
Item item
in itemsInScene )
160 sceneItem.m_ItemCode = item.
ItemCode;
161 sceneItem.m_Position =
new Vector3Serializable( item.transform.position.x, item.transform.position.y, item.transform.position.z );
162 sceneItem.m_ItemName = item.name;
165 sceneItemList.Add( sceneItem );
170 sceneSave.m_ListSceneItem = sceneItemList;
Store all scenes in here. If we have 3 scenes, we have 3 entries.
Dictionary< string, SceneSave > m_SceneData
Assign a unique GUID for the objects. These ids are used to retrive the gameobjects when restoring sc...
void Init(int itemCode)
At the start if we have a reapable item, we add the item nudge class.
Manage saving and loading scenes. This class is a singleton instance.
We have scene item instances for every item in the scene that we want to store in a save file.
Vector3Serializable m_Position
Control store, restore, save and load functionality in the scene.
void ISaveableRestoreScene(string sceneName)
Restore the scene
void InstantiateSceneItems(List< SceneItem > sceneItemList)
Loop through all the scene items Then instantiate a game object for each SceneItem
void ISaveableStoreScene(string sceneName)
Remove old scene data Save all the information on new scene Add that back to the GameObjectSave
void ISaveableRegister()
Adding the current game object to iSaveableObjectList instance in SaveLoadManager
void DestroySceneItems()
Destroy Items currently in the scene
GameObjectSave m_GameObjectSave
void AfterSceneLoad()
Find the game object of the parent
override void Awake()
Call the base of singleton class Initialize variables.
void InstantiateSceneItem(int itemCode, Vector3 itemPosition)
For future. Use to instantiate a single SceneItem
GameObjectSave GameObjectSave
void OnDisable()
Calls ISaveableDeregister Unsubscribe from AfterSceneLoad
void ISaveableDeregister()
Removing the current game object to iSaveableObjectList instance in SaveLoadManager
void OnEnable()
Calls ISaveableRegister Subscribe to AfterSceneLoad
Store all of the scene items in this list.
Abstract class that inherited by all the game managers. All the game managers use singleton since gam...
Unity Vector3 data type is NOT serializable. Therefore, it can't be searilize and saved to a datafile...
Interface for unity ISaveable