From d4b0f45adee587592a0f88b82f76b8f6ebe48816 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 31 Jan 2017 11:28:13 +0000 Subject: [PATCH] Added Delete Save Data button to Save Menu inspector. --- Assets/Fungus/Scripts/Components/SaveMenu.cs | 7 +++- .../Fungus/Scripts/Editor/SaveMenuEditor.cs | 33 +++++++++++++++++++ .../Scripts/Editor/SaveMenuEditor.cs.meta | 12 +++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs create mode 100644 Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs.meta diff --git a/Assets/Fungus/Scripts/Components/SaveMenu.cs b/Assets/Fungus/Scripts/Components/SaveMenu.cs index f69ef89a..f11a3884 100644 --- a/Assets/Fungus/Scripts/Components/SaveMenu.cs +++ b/Assets/Fungus/Scripts/Components/SaveMenu.cs @@ -14,7 +14,7 @@ namespace Fungus /// public class SaveMenu : MonoBehaviour { - [Tooltip("Save Data Key: The string key used to store save game data in Player Prefs. If you have multiple games defined in the same Unity project, use a unique key for each one.")] + [Tooltip("The string key used to store save game data in Player Prefs. If you have multiple games defined in the same Unity project, use a unique key for each one.")] [SerializeField] protected string saveDataKey = FungusConstants.DefaultSaveDataKey; [Tooltip("Automatically load the most recently saved game on startup")] @@ -175,6 +175,11 @@ namespace Fungus #region Public methods + /// + /// Gets the string key used to store save game data in Player Prefs. + /// + public virtual string SaveDataKey { get { return saveDataKey; } } + /// /// Toggles the expanded / collapsed state of the save menu. /// Uses a tween to fade the menu UI in and out. diff --git a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs new file mode 100644 index 00000000..78e19a76 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs @@ -0,0 +1,33 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +#if UNITY_5_3_OR_NEWER + +using UnityEngine; +using UnityEditor; +using Rotorz.ReorderableList; + +namespace Fungus.EditorUtils +{ + [CustomEditor (typeof(SaveMenu), true)] + public class SaveMenuEditor : Editor + { + public override void OnInspectorGUI() + { + if (GUILayout.Button(new GUIContent("Delete Save Data", "Deletes the save data associated with the Save Data Key from PlayerPrefs"))) + { + var saveMenu = target as SaveMenu; + + if (saveMenu != null) + { + PlayerPrefs.DeleteKey(saveMenu.SaveDataKey); + FlowchartWindow.ShowNotification("Deleted Save Data"); + } + } + + base.OnInspectorGUI(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs.meta new file mode 100644 index 00000000..001683bd --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 14f55202ca4374124a4d74ab9276e28f +timeCreated: 1484049679 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: