From 1b5a197b102f8fe2ca21e653ddf2c8b08cc3da9c Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Wed, 4 Sep 2019 17:38:47 +1000 Subject: [PATCH 1/3] Add button to Fungus Editor Prefs to locate the FungusEditorResources SO, makes it easier to find and regenerate --- .../Scripts/Editor/FungusEditorPreferences.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs index a69fd9f0..6d1d55db 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs @@ -47,6 +47,19 @@ namespace Fungus hideMushroomInHierarchy = EditorGUILayout.Toggle("Hide Mushroom Flowchart Icon", hideMushroomInHierarchy); useLegacyMenus = EditorGUILayout.Toggle(new GUIContent("Legacy Menus", "Force Legacy menus for Event, Add Variable and Add Command menus"), useLegacyMenus); + EditorGUILayout.Space(); + GUILayout.Label("If Fungus icons are not showing correctly you may need to reassign the references in the FungusEditorResources. Button below will locate it."); + if (GUILayout.Button("Select Fungus Editor Resources SO")) + { + var ids = AssetDatabase.FindAssets("t:FungusEditorResources"); + if (ids.Length > 0) + { + var p = AssetDatabase.GUIDToAssetPath(ids[0]); + var asset = AssetDatabase.LoadAssetAtPath(p); + Selection.activeObject = asset; + } + } + // Save the preferences if (GUI.changed) { From d86197bb39e58d4f7a09046bc7ffd3bd517d5385 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Thu, 5 Sep 2019 20:15:35 +1000 Subject: [PATCH 2/3] Fungus Prefs show an error if Add button texture is missing, indication that FungusEditorResources need to be relocated Added button to open the fungus changelog, to assist with users determining versions --- .../Scripts/Editor/FungusEditorPreferences.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs index 6d1d55db..d6402ceb 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs @@ -48,8 +48,13 @@ namespace Fungus useLegacyMenus = EditorGUILayout.Toggle(new GUIContent("Legacy Menus", "Force Legacy menus for Event, Add Variable and Add Command menus"), useLegacyMenus); EditorGUILayout.Space(); - GUILayout.Label("If Fungus icons are not showing correctly you may need to reassign the references in the FungusEditorResources. Button below will locate it."); - if (GUILayout.Button("Select Fungus Editor Resources SO")) + //ideally if any are null, but typically it is all or nothing that have broken links due to version changes or moving files external to Unity + if(FungusEditorResources.Add == null) + { + EditorGUILayout.HelpBox("FungusEditorResources need to be regenerated!", MessageType.Error); + } + + if (GUILayout.Button(new GUIContent("Select Fungus Editor Resources SO", "If Fungus icons are not showing correctly you may need to reassign the references in the FungusEditorResources. Button below will locate it."))) { var ids = AssetDatabase.FindAssets("t:FungusEditorResources"); if (ids.Length > 0) @@ -60,6 +65,12 @@ namespace Fungus } } + if(GUILayout.Button("Open Changelog (version info)")) + { + var fileMacthes = System.IO.Directory.GetFiles(Application.dataPath, "Fungus\\Docs\\CHANGELOG.txt", System.IO.SearchOption.AllDirectories); + Application.OpenURL(fileMacthes[0]); + } + // Save the preferences if (GUI.changed) { From 4aea552456e4f1ef95f2fe58e19f121cb2c195a0 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sat, 5 Oct 2019 16:10:15 +1000 Subject: [PATCH 3/3] EditorResources and Changelog locators more verbose logs on failure ChangeLog searches from Unity project root, not just within Assets folder --- .../Scripts/Editor/FungusEditorPreferences.cs | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs index d6402ceb..3dc30af3 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs @@ -1,6 +1,6 @@ -using UnityEngine; +using System.Linq; using UnityEditor; -using UnityEditor.Callbacks; +using UnityEngine; namespace Fungus { @@ -16,8 +16,8 @@ namespace Fungus { // Have we loaded the prefs yet private static bool prefsLoaded = false; - const string HIDE_MUSH_KEY = "hideMushroomInHierarchy"; - const string USE_LEGACY_MENUS = "useLegacyMenus"; + private const string HIDE_MUSH_KEY = "hideMushroomInHierarchy"; + private const string USE_LEGACY_MENUS = "useLegacyMenus"; public static bool hideMushroomInHierarchy; public static bool useLegacyMenus; @@ -49,7 +49,7 @@ namespace Fungus EditorGUILayout.Space(); //ideally if any are null, but typically it is all or nothing that have broken links due to version changes or moving files external to Unity - if(FungusEditorResources.Add == null) + if (FungusEditorResources.Add == null) { EditorGUILayout.HelpBox("FungusEditorResources need to be regenerated!", MessageType.Error); } @@ -63,12 +63,32 @@ namespace Fungus var asset = AssetDatabase.LoadAssetAtPath(p); Selection.activeObject = asset; } + else + { + Debug.LogError("No FungusEditorResources found!"); + } } - if(GUILayout.Button("Open Changelog (version info)")) + if (GUILayout.Button("Open Changelog (version info)")) { - var fileMacthes = System.IO.Directory.GetFiles(Application.dataPath, "Fungus\\Docs\\CHANGELOG.txt", System.IO.SearchOption.AllDirectories); - Application.OpenURL(fileMacthes[0]); + //From project path down, look for our Fungus\Docs\ChangeLog.txt + var projectPath = System.IO.Directory.GetParent(Application.dataPath); + var fileMacthes = System.IO.Directory.GetFiles(projectPath.FullName, "CHANGELOG.txt", System.IO.SearchOption.AllDirectories); + + fileMacthes = fileMacthes.Where((x) => + { + var fileFolder = System.IO.Directory.GetParent(x); + return fileFolder.Name == "Docs" && fileFolder.Parent.Name == "Fungus"; + }).ToArray(); + + if (fileMacthes == null || fileMacthes.Length == 0) + { + Debug.LogWarning("Cannot locate Fungus\\Docs\\CHANGELONG.txt"); + } + else + { + Application.OpenURL(fileMacthes[0]); + } } // Save the preferences