From 265b1b2f83b18911be3d2d24ad337d2374e7123e Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Tue, 15 May 2018 20:01:29 +1000 Subject: [PATCH] Isolated rotorz to CommandListAdaptor and VariableListAdaptor -some lists/arrays were reorderable when they did not need to be and thus are removed for right now --- Assets/Fungus/Scripts/Commands/SetCollider.cs | 5 +++ Assets/Fungus/Scripts/Editor/BlockEditor.cs | 16 +------- .../Fungus/Scripts/Editor/CharacterEditor.cs | 4 +- Assets/Fungus/Scripts/Editor/CommandEditor.cs | 33 +++++++++++++-- .../Scripts/Editor/CommandListAdaptor.cs | 18 +++++++++ .../Fungus/Scripts/Editor/FlowchartEditor.cs | 13 ++---- .../Fungus/Scripts/Editor/SaveDataEditor.cs | 34 ---------------- .../Scripts/Editor/SaveDataEditor.cs.meta | 12 ------ .../Fungus/Scripts/Editor/SaveMenuEditor.cs | 1 - .../Scripts/Editor/SavePointLoadedEditor.cs | 30 -------------- .../Editor/SavePointLoadedEditor.cs.meta | 12 ------ .../Scripts/Editor/SetColliderEditor.cs | 40 ------------------- .../Scripts/Editor/SetColliderEditor.cs.meta | 12 ------ .../Scripts/Editor/VariableListAdaptor.cs | 10 +++++ .../Scripts/Editor/WriterAudioEditor.cs | 4 +- 15 files changed, 69 insertions(+), 175 deletions(-) delete mode 100644 Assets/Fungus/Scripts/Editor/SaveDataEditor.cs delete mode 100644 Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta delete mode 100644 Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs delete mode 100644 Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta delete mode 100644 Assets/Fungus/Scripts/Editor/SetColliderEditor.cs delete mode 100644 Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs index b56a64f5..ef623040 100644 --- a/Assets/Fungus/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs @@ -97,6 +97,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool IsReorderableArray(string propertyName) + { + return propertyName == "targetObjects"; + } + #endregion } diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 055f9a9c..8d404755 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -9,7 +9,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using Rotorz.ReorderableList; using System.IO; using System.Reflection; @@ -150,20 +149,7 @@ namespace Fungus.EditorUtils command.ParentBlock = block; } - ReorderableListGUI.Title("Commands"); - CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0); - adaptor.nodeRect = block._NodeRect; - - ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu; - - if (block.CommandList.Count == 0) - { - EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info); - } - else - { - ReorderableListControl.DrawControlFromState(adaptor, null, flags); - } + CommandListAdaptor.DrawCommandList(block, commandListProperty); // EventType.contextClick doesn't register since we moved the Block Editor to be inside // a GUI Area, no idea why. As a workaround we just check for right click instead. diff --git a/Assets/Fungus/Scripts/Editor/CharacterEditor.cs b/Assets/Fungus/Scripts/Editor/CharacterEditor.cs index 7bab1484..60c4bbaf 100644 --- a/Assets/Fungus/Scripts/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Scripts/Editor/CharacterEditor.cs @@ -3,7 +3,6 @@ using UnityEditor; using UnityEngine; -using Rotorz.ReorderableList; namespace Fungus.EditorUtils { @@ -60,8 +59,7 @@ namespace Fungus.EditorUtils GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect); } - ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog")); - ReorderableListGUI.ListField(portraitsProp); + EditorGUILayout.PropertyField(portraitsProp, new GUIContent("Portraits", "Character image sprites to display in the dialog"), true); EditorGUILayout.HelpBox("All portrait images should use the exact same resolution to avoid positioning and tiling issues.", MessageType.Info); diff --git a/Assets/Fungus/Scripts/Editor/CommandEditor.cs b/Assets/Fungus/Scripts/Editor/CommandEditor.cs index 05ae1e17..56b50f30 100644 --- a/Assets/Fungus/Scripts/Editor/CommandEditor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandEditor.cs @@ -4,14 +4,14 @@ using UnityEditor; using UnityEngine; using System.Collections.Generic; -using Rotorz.ReorderableList; +using UnityEditorInternal; namespace Fungus.EditorUtils { - [CustomEditor (typeof(Command), true)] public class CommandEditor : Editor { + #region statics public static Command selectedCommand; public static CommandInfoAttribute GetCommandInfo(System.Type commandType) @@ -34,6 +34,15 @@ namespace Fungus.EditorUtils return retval; } + #endregion statics + + private Dictionary reorderableLists; + + public virtual void OnEnable() + { + reorderableLists = new Dictionary(); + } + public virtual void DrawCommandInspectorGUI() { Command t = target as Command; @@ -148,8 +157,24 @@ namespace Fungus.EditorUtils if (iterator.isArray && t.IsReorderableArray(iterator.name)) { - ReorderableListGUI.Title(new GUIContent(iterator.displayName, iterator.tooltip)); - ReorderableListGUI.ListField(iterator); + ReorderableList reordList = null; + reorderableLists.TryGetValue(iterator.displayName, out reordList); + if(reordList == null) + { + var locSerProp = iterator.Copy(); + //create and insert + reordList = new ReorderableList(serializedObject, locSerProp, true, false, true, true) + { + drawHeaderCallback = (Rect rect) => + { + EditorGUI.LabelField(rect, locSerProp.displayName); + } + }; + + reorderableLists.Add(iterator.displayName, reordList); + } + + reordList.DoLayoutList(); } else { diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs index 117a7f40..d3c6aa98 100644 --- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs @@ -14,6 +14,24 @@ namespace Fungus.EditorUtils { public class CommandListAdaptor : IReorderableListAdaptor { + public static void DrawCommandList(Block block, SerializedProperty commandListProperty) + { + ReorderableListGUI.Title("Commands"); + CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0); + adaptor.nodeRect = block._NodeRect; + + ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu; + + if (block.CommandList.Count == 0) + { + EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info); + } + else + { + ReorderableListControl.DrawControlFromState(adaptor, null, flags); + } + } + protected SerializedProperty _arrayProperty; public float fixedItemHeight; diff --git a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs index 52d79d61..fe5a97dd 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs @@ -4,7 +4,6 @@ using UnityEditor; using UnityEngine; using System.Collections.Generic; -using Rotorz.ReorderableList; using System.Linq; using System.Reflection; @@ -72,8 +71,9 @@ namespace Fungus.EditorUtils EditorGUILayout.PropertyField(luaBindingNameProp); // Show list of commands to hide in Add Command menu - ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip)); - ReorderableListGUI.ListField(hideCommandsProp); + //ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip)); + //ReorderableListGUI.ListField(hideCommandsProp); + EditorGUILayout.PropertyField(hideCommandsProp, new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip), true); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); @@ -134,12 +134,7 @@ namespace Fungus.EditorUtils } } - ReorderableListGUI.Title("Variables"); - VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w); - - ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton; - - ReorderableListControl.DrawControlFromState(adaptor, null, flags); + VariableListAdaptor.DrawVarList(w, variablesProp); listRect = GUILayoutUtility.GetLastRect(); diff --git a/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs b/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs deleted file mode 100644 index 4a060e32..00000000 --- a/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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(SaveData), true)] - public class SaveDataEditor : Editor - { - protected SerializedProperty flowchartsProp; - - protected virtual void OnEnable() - { - flowchartsProp = serializedObject.FindProperty("flowcharts"); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - ReorderableListGUI.Title("Flowcharts"); - ReorderableListGUI.ListField(flowchartsProp); - - serializedObject.ApplyModifiedProperties(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta deleted file mode 100644 index 94ccf3b2..00000000 --- a/Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 395934d0b0e6a48a396a25348aeaade5 -timeCreated: 1484049679 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs index 78e19a76..6286eab1 100644 --- a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs +++ b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs @@ -5,7 +5,6 @@ using UnityEngine; using UnityEditor; -using Rotorz.ReorderableList; namespace Fungus.EditorUtils { diff --git a/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs b/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs deleted file mode 100644 index 9ff2532f..00000000 --- a/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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(SavePointLoaded), true)] - public class SavePointLoadedEditor : EventHandlerEditor - { - protected SerializedProperty savePointKeysProp; - - protected virtual void OnEnable() - { - savePointKeysProp = serializedObject.FindProperty("savePointKeys"); - } - - protected override void DrawProperties() - { - ReorderableListGUI.Title("Save Point Keys"); - ReorderableListGUI.ListField(savePointKeysProp); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta deleted file mode 100644 index 4e2c4995..00000000 --- a/Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8514e225c506c4938a5da19210cc6217 -timeCreated: 1484049679 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs b/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs deleted file mode 100644 index 6abbf209..00000000 --- a/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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) - -using UnityEditor; -using UnityEngine; -using Rotorz.ReorderableList; - -namespace Fungus.EditorUtils -{ - [CustomEditor (typeof(SetCollider))] - public class SetColliderEditor : CommandEditor - { - protected SerializedProperty targetObjectsProp; - protected SerializedProperty targetTagProp; - protected SerializedProperty activeStateProp; - - protected virtual void OnEnable() - { - if (NullTargetCheck()) // Check for an orphaned editor instance - return; - - targetObjectsProp = serializedObject.FindProperty("targetObjects"); - targetTagProp = serializedObject.FindProperty("targetTag"); - activeStateProp = serializedObject.FindProperty("activeState"); - } - - public override void DrawCommandGUI() - { - serializedObject.Update(); - - ReorderableListGUI.Title(new GUIContent("Target Objects", "Objects containing collider components (2D or 3D)")); - ReorderableListGUI.ListField(targetObjectsProp); - - EditorGUILayout.PropertyField(targetTagProp); - EditorGUILayout.PropertyField(activeStateProp); - - serializedObject.ApplyModifiedProperties(); - } - } -} diff --git a/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta deleted file mode 100644 index f0f8604f..00000000 --- a/Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 672281668cfa249738d9dbc91f96b88e -timeCreated: 1432222536 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs index 07b161d9..0ec5bb07 100644 --- a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs @@ -25,6 +25,16 @@ namespace Fungus.EditorUtils public int widthOfList; + static public void DrawVarList(int w, SerializedProperty variablesProp) + { + ReorderableListGUI.Title("Variables"); + VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w); + + ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton; + + ReorderableListControl.DrawControlFromState(adaptor, null, flags); + } + public SerializedProperty this[int index] { get { return _arrayProperty.GetArrayElementAtIndex(index); } diff --git a/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs b/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs index 35c31fb7..9a812922 100644 --- a/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs +++ b/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs @@ -3,7 +3,6 @@ using UnityEditor; using UnityEngine; -using Rotorz.ReorderableList; namespace Fungus.EditorUtils { @@ -41,8 +40,7 @@ namespace Fungus.EditorUtils EditorGUILayout.PropertyField(audioModeProp); if ((AudioMode)audioModeProp.enumValueIndex == AudioMode.Beeps) { - ReorderableListGUI.Title(new GUIContent("Beep Sounds", "A list of beep sounds to play at random")); - ReorderableListGUI.ListField(beepSoundsProp); + EditorGUILayout.PropertyField(beepSoundsProp, new GUIContent("Beep Sounds", "A list of beep sounds to play at random"),true); } else {