public override void OnGUI(DatabaseEditor ed, LoadSaveProviderBase loadSaveProvider) { //DefaultLoadSave provider = laodSaveProvider as DefaultLoadSave; EditorGUILayout.BeginVertical(UniRPGEdGui.BoxStyle, GUILayout.MaxWidth(350)); { GUILayout.Label("This is the Default UniRPG LoadSave Provider.\nIt makes use of Unity's PlayerPrefs to save game state."); } EditorGUILayout.EndVertical(); }
void Start() { #if UNITY_EDITOR // During development a designer might Play another scene which would load this one. // In that case I do not want to force load the MENUGUI except if dev played the "unirpg" scene directly if (Application.loadedLevelName.Equals("unirpg")) { ShowLoading(State.LoadingMainMenu_Step1); //Application.LoadLevelAdditiveAsync("menudata"); UniRPGGlobal.LoadLevelAdditive("menudata"); } #else // load the main menu scene now ShowLoading(State.LoadingMainMenu_Step1); //Application.LoadLevelAdditiveAsync("menudata"); UniRPGGlobal.LoadLevelAdditive("menudata"); #endif // create the LoadSave Provider instance if (_db.loadSaveProviderPrefab) { GameObject go = (GameObject)GameObject.Instantiate(_db.loadSaveProviderPrefab); go.name = "LoadSave Provider"; go.transform.parent = transform; loadSaveProvider = go.GetComponent<LoadSaveProviderBase>(); } if (loadSaveProvider == null) { Debug.LogError("No LoadSave Provider found. This will cause errors."); } else { // load info on the saved data (save slots) int count = 0; count = loadSaveProvider.GetInt("saveslots", 0); if (count > 0) { for (int i = 0; i < count; i++) { string s = loadSaveProvider.GetString("saveslot" + i, null); if (!string.IsNullOrEmpty(s)) { string[] vs = s.Split('|'); SaveSlots.Add(vs[0], vs[1]); } } } } LoadGameSettings(); }
public virtual void OnGUI(DatabaseEditor ed, LoadSaveProviderBase loadSaveProvider) { }
public static void InitLoadSaveProvider(Database db, int forceUsing) { activeLoadSaveIdx = -1; if (LoadSaveEditors.Length >= 0) { if (db.loadSaveProviderPrefab && forceUsing == -1) { // first try and find out what provider was selected previously and init with it, if possible LoadSaveProviderBase provider = db.loadSaveProviderPrefab.GetComponent<LoadSaveProviderBase>(); if (provider) { for (int i = 0; i < LoadSaveEditors.Length; i++) { if (provider.providerName.Equals(LoadSaveEditors[i].name)) { activeLoadSaveIdx = i; currLoadSaveProvider = provider; break; } } } } // if idx == -1 then one is not selected and must be added now if (activeLoadSaveIdx == -1) { if (forceUsing == -1) { // will select UniRPG's default provider for (int i = 0; i < LoadSaveEditors.Length; i++) { if (LoadSaveEditors[i].providerType == typeof(DefaultLoadSave)) { activeLoadSaveIdx = i; break; } } if (activeLoadSaveIdx == -1) activeLoadSaveIdx = 0; // else grab first avail } else activeLoadSaveIdx = forceUsing; // create object & save as prefab Object prefab = PrefabUtility.CreateEmptyPrefab(LOADSAVE_PREFAB); GameObject go = new GameObject("LoadSave Provider"); // create temp object in scene go.AddComponent(LoadSaveEditors[activeLoadSaveIdx].providerType); GameObject lspPrefab = PrefabUtility.ReplacePrefab(go, prefab); // save prefab GameObject.DestroyImmediate(go); // wipe temp object from scene db.loadSaveProviderPrefab = lspPrefab; currLoadSaveProvider = db.loadSaveProviderPrefab.GetComponent<LoadSaveProviderBase>(); currLoadSaveProvider.providerName = LoadSaveEditors[activeLoadSaveIdx].name; EditorUtility.SetDirty(db.loadSaveProviderPrefab); EditorUtility.SetDirty(db); AssetDatabase.SaveAssets(); } } }