Beispiel #1
0
        private void Start()
        {
            cachedSaveData = SaveUtility.LoadSave(saveSlot.Value);
            if (cachedSaveData == null)
            {
                Debug.Log("cachedSaveData == null");
                CreateNewSave();
            }

            onGameLoad?.Invoke(cachedSaveData);
        }
Beispiel #2
0
        public void OnLoad(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            currentSaveGame = SaveUtility.LoadSave(currentSaveSlot.Value);

            if (currentSaveGame == null)
            {
                Debug.Log("Could not find current save");
                return;
            }
            SaveData saveData = JsonUtility.FromJson <SaveData>(data);

            if (saveData.data != null && saveData.data.Count > 0)
            {
                for (int i = 0; i < saveData.data.Count; i++)
                {
                    SaveablePrefab saveablePrefab = ScriptableAssetDatabase.GetAsset(saveData.data[i].prefabGUID) as SaveablePrefab;

                    if (saveablePrefab == null)
                    {
                        //Debug.Log(saveData.data[i]);
                        Debug.Log($"Could not find reference in ScriptableAssetDatabase for Saveable Prefab : {saveData.data[i].prefabGUID}");
                        continue;
                    }

                    for (int i2 = 0; i2 < saveData.data[i].saveableGUIDs.Count; i2++)
                    {
                        Saveable getSaveable = saveablePrefab.Retrieve <Saveable>(saveData.data[i].saveableGUIDs[i2]);
                        getSaveable.OnLoadRequest(currentSaveGame);

#if UNITY_EDITOR
                        getSaveable.transform.SetParent(this.transform, true);
#endif
                    }
                }
            }
        }
Beispiel #3
0
 public void Initialize()
 {
     cachedSaveData = SaveUtility.LoadSave(saveSlot.Value);
 }
Beispiel #4
0
 public void OnLoadSystem()
 {
     cachedSaveData = SaveUtility.LoadSave(saveSlot.Value);
 }