public override void OnInspectorGUI() { if (SerializableManager.current != target) { GUI.color = Color.red; EditorGUILayout.HelpBox("You can only have one instance of Serializable Manager at the same time.", MessageType.Error, true); if (SerializableManager.current == null && SerializableManager.current != (SerializableManager)target) { SerializableManager.current = ((SerializableManager)target); } return; } DrawDefaultInspector(); serializedObject.Update(); if (serializedObject.FindProperty("Encrypt").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("password"), true); if (passwordWarning > Time.realtimeSinceStartup || (lastpassword != "" && lastpassword != serializedObject.FindProperty("password").stringValue)) { EditorGUILayout.HelpBox("Change the password will cause can not be loaded old games", MessageType.Warning, true); if (passwordWarning < Time.realtimeSinceStartup) { passwordWarning = Time.realtimeSinceStartup + 20; } } lastpassword = serializedObject.FindProperty("password").stringValue; } if (serializedObject.FindProperty("AutoSave").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("TimeBetweenSavedSeconds"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("CurrentTimeToSave"), true); } GUI.enabled = Application.isPlaying; if (GUILayout.Button("Save All")) { SerializableManager.SaveAll(); } if (GUILayout.Button("Load All")) { SerializableManager.LoadAll(); } if (!Application.isPlaying) { GUI.enabled = true; GUI.color = Color.yellow; EditorGUILayout.HelpBox("You can only save and load in play mode", MessageType.Warning, true); GUI.color = Color.white; } serializedObject.ApplyModifiedProperties(); }
void OnGUI() { if (GUI.Button(new Rect(10, 10, 150, 20), "Save Game")) { SerializableManager.SaveAll(); } if (GUI.Button(new Rect(10, 50, 150, 20), "Load Game")) { //to erase those now! foreach (exampleCube cubes in GameObject.FindObjectsOfType <exampleCube>()) { Destroy(cubes.gameObject); } SerializableManager.LoadAll(); } GUI.Label(new Rect(10, 300, 200, 20), "Time: " + (int)time); }