void LoadDataEditor() { PersistentDataSystem persistentData = ((PersistentDataSystem)target); GUILayout.BeginVertical(EditorStyles.textArea); GUILayout.Space(2); GUIStyle option = new GUIStyle(); option.alignment = TextAnchor.MiddleCenter; option.fontSize = 15; option.fontStyle = FontStyle.Bold; GUILayout.Label("LOAD", option); GUILayout.Space(20); option.fontSize = 10; GUILayout.Label("Player", option); GUILayout.Space(5); if (persistentData.awakeLoadMode == PersistentDataSystem.AwakeLoadMode.SPECIFIC_CLASS && GUILayout.Button("Load specific player class data")) { persistentData.LoadClass(persistentData.classToLoad); } GUILayout.Space(2); if (GUILayout.Button("Load all player saved data")) { persistentData.LoadAllSavedData(); } GUILayout.Space(2); if (GUILayout.Button("Erase all player saved data")) { persistentData.EraseAllSavedData(); } GUILayout.Space(10); GUILayout.Label("Default", option); GUILayout.Space(5); if (persistentData.awakeLoadMode == PersistentDataSystem.AwakeLoadMode.SPECIFIC_CLASS && GUILayout.Button("Load specific default class data")) { persistentData.LoadClass(persistentData.classToLoad, PersistentDataSystem.PathMode.DEFAULT); } GUILayout.Space(2); if (GUILayout.Button("Load all default saved data")) { persistentData.LoadAllSavedData(PersistentDataSystem.PathMode.DEFAULT); } GUILayout.Space(2); if (GUILayout.Button("Erase all default saved data")) { persistentData.EraseAllSavedData(PersistentDataSystem.PathMode.DEFAULT); AssetDatabase.Refresh(ImportAssetOptions.Default); } GUILayout.EndVertical(); GUILayout.Space(2); }
public void DeleteGhost() { if (index == 0) { return; } ghosts.RemoveAt(index - 1); PersistentDataSystem inst = PersistentDataSystem.Instance; inst.EraseAllSavedData(); inst.Init(); ghosts.ForEach(inst.AddSavedDataToDictionnary); inst.SaveAllData(); ResetList(); }
public override void OnInspectorGUI() { PersistentDataSystem persistentData = ((PersistentDataSystem)target); persistentData.dataVersion = EditorGUILayout.TextField("DataVersion", persistentData.dataVersion); persistentData.autoSave = EditorGUILayout.Toggle("AutoSave", persistentData.autoSave); persistentData.saveMode = (PersistentDataSystem.SaveMode)(EditorGUILayout.EnumPopup("SaveMode", persistentData.saveMode)); EditorGUILayout.Space(); PersistentDataSystem.LoadMode persistentDataSystemLoadMode = ((PersistentDataSystem.LoadMode)(serializedObject.FindProperty("loadAwakeMode").enumValueIndex)); serializedObject.FindProperty("loadAwakeMode").enumValueIndex = (int)(PersistentDataSystem.LoadMode)(EditorGUILayout.EnumPopup("LoadAwakeMode", persistentDataSystemLoadMode)); if (persistentDataSystemLoadMode == PersistentDataSystem.LoadMode.SPECIFIC_CLASS) { persistentData.classToLoad = (string[])EditorUtils.GenericField("Class to load", persistentData.classToLoad, typeof(string[])); } EditorGUILayout.Space(); if (!persistentData.IsInit) { persistentData.Init(); } GUILayout.Space(10); if (persistentData.savedDataDictionnary != null) { foreach (List <SavedData> sdList in persistentData.savedDataDictionnary.Values) { if (sdList != null && sdList.Count > 0) { GUILayout.BeginVertical(EditorStyles.textArea); GUILayout.Space(2); GUIStyle option = new GUIStyle(); option.alignment = TextAnchor.MiddleCenter; option.fontSize = 15; option.fontStyle = FontStyle.Bold; GUILayout.Label(sdList[0].GetType().Name, option); GUILayout.Space(5); foreach (SavedData sd in sdList) { sd.DisplayInspector(); GUILayout.Space(2); } GUILayout.EndVertical(); GUILayout.Space(2); } } if (persistentData.savedDataDictionnary.Count > 0 && GUILayout.Button("Save Data")) { persistentData.SaveAllData(); Debug.Log("Data Saved in the Directory : " + persistentData.AutomaticSavedDataDirectoryPath); } } GUILayout.Space(2); if (persistentDataSystemLoadMode == PersistentDataSystem.LoadMode.SPECIFIC_CLASS && GUILayout.Button("Load specific class data")) { persistentData.LoadClass(persistentData.classToLoad); } GUILayout.Space(2); if (GUILayout.Button("Load all saved data")) { persistentData.LoadAllSavedData(); } GUILayout.Space(2); if (GUILayout.Button("Unload saved data")) { persistentData.UnloadAllSavedData(); } GUILayout.Space(2); if (GUILayout.Button("Erase all saved data")) { persistentData.EraseAllSavedData(); } serializedObject.ApplyModifiedProperties(); }