Browse Source

Defines and fallbacks for 2017 and 2018 (#781)

master
Steve Halliwell 5 years ago committed by GitHub
parent
commit
ce7e75aa50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  2. 133
      Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
  3. 4
      Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs
  4. 4
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/MenuItems.cs

10
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -1257,10 +1257,10 @@ namespace Fungus.EditorUtils
}
else
{
menu.AddDisabledItem(new GUIContent("StopAll"), false);//, () => StopAllBlocks());
menu.AddDisabledItem(new GUIContent("Stop"), false);//, () => StopThisBlock(hitBlock));
menu.AddDisabledItem(new GUIContent("Execute"), false);//, () => ExecuteThisBlock(hitBlock, false));
menu.AddDisabledItem(new GUIContent("Execute (Stop All First)"), false);//, () => ExecuteThisBlock(hitBlock, true));
menu.AddDisabledItem(new GUIContent("StopAll"));//, false), () => StopAllBlocks());
menu.AddDisabledItem(new GUIContent("Stop"));//, false);, () => StopThisBlock(hitBlock));
menu.AddDisabledItem(new GUIContent("Execute"));//, false);, () => ExecuteThisBlock(hitBlock, false));
menu.AddDisabledItem(new GUIContent("Execute (Stop All First)"));//, false);, () => ExecuteThisBlock(hitBlock, true));
}
}
else
@ -1285,7 +1285,7 @@ namespace Fungus.EditorUtils
}
else
{
menu.AddDisabledItem(new GUIContent("StopAll"), false);//, () => StopAllBlocks());
menu.AddDisabledItem(new GUIContent("StopAll"));//, false);, () => StopAllBlocks());
}
}

133
Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs

@ -27,6 +27,7 @@ namespace Fungus
LoadOnScriptLoad();
}
#if UNITY_2019_1_OR_NEWER
[SettingsProvider]
public static SettingsProvider CreateFungusSettingsProvider()
{
@ -35,69 +36,7 @@ namespace Fungus
var provider = new SettingsProvider("Project/Fungus", SettingsScope.Project)
{
// Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
guiHandler = (searchContext) =>
{
// Load the preferences
if (!prefsLoaded)
{
LoadOnScriptLoad();
}
// Preferences GUI
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();
//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)
{
var p = AssetDatabase.GUIDToAssetPath(ids[0]);
var asset = AssetDatabase.LoadAssetAtPath<FungusEditorResources>(p);
Selection.activeObject = asset;
}
else
{
Debug.LogError("No FungusEditorResources found!");
}
}
if (GUILayout.Button("Open Changelog (version info)"))
{
//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
if (GUI.changed)
{
EditorPrefs.SetBool(HIDE_MUSH_KEY, hideMushroomInHierarchy);
EditorPrefs.SetBool(USE_LEGACY_MENUS, useLegacyMenus);
}
},
guiHandler = (searchContext) => PreferencesGUI()
// // Populate the search keywords to enable smart search filtering and label highlighting:
// keywords = new HashSet<string>(new[] { "Number", "Some String" })
@ -106,6 +45,74 @@ namespace Fungus
return provider;
}
#else
[PreferenceItem("Fungus")]
#endif
private static void PreferencesGUI()
{
// Load the preferences
if (!prefsLoaded)
{
LoadOnScriptLoad();
}
// Preferences GUI
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();
//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)
{
var p = AssetDatabase.GUIDToAssetPath(ids[0]);
var asset = AssetDatabase.LoadAssetAtPath<FungusEditorResources>(p);
Selection.activeObject = asset;
}
else
{
Debug.LogError("No FungusEditorResources found!");
}
}
if (GUILayout.Button("Open Changelog (version info)"))
{
//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
if (GUI.changed)
{
EditorPrefs.SetBool(HIDE_MUSH_KEY, hideMushroomInHierarchy);
EditorPrefs.SetBool(USE_LEGACY_MENUS, useLegacyMenus);
}
}
public static void LoadOnScriptLoad()
{
hideMushroomInHierarchy = EditorPrefs.GetBool(HIDE_MUSH_KEY, false);

4
Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs

@ -4,7 +4,8 @@ using System.IO;
namespace Fungus.EditorUtils
{
[ScriptedImporter(1, "lua")]
#if UNITY_2018_4_OR_NEWER
[ScriptedImporter(1, "lua")]
public class LuaScriptedImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
@ -14,4 +15,5 @@ namespace Fungus.EditorUtils
ctx.SetMainObject(lua);
}
}
#endif
}

4
Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/MenuItems.cs vendored

@ -77,7 +77,11 @@ namespace Fungus
}
GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
#if UNITY_2018_4_OR_NEWER
PrefabUtility.UnpackPrefabInstance(go, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
#else
PrefabUtility.DisconnectPrefabInstance(go);
#endif
if (centerInScene)
{

Loading…
Cancel
Save