diff --git a/Assets/Fungus/Flowchart/Editor/CommandEditor.cs b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs index 7a469c81..2d5ef045 100644 --- a/Assets/Fungus/Flowchart/Editor/CommandEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs @@ -3,6 +3,7 @@ using UnityEditorInternal; using UnityEngine; using System.Collections; using System.Collections.Generic; +using Rotorz.ReorderableList; namespace Fungus { @@ -113,6 +114,8 @@ namespace Fungus public virtual void DrawCommandGUI() { + Command t = target as Command; + // Code below was copied from here // http://answers.unity3d.com/questions/550829/how-to-add-a-script-field-in-custom-inspector.html @@ -131,7 +134,20 @@ namespace Fungus continue; } - EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); + if (!t.IsPropertyVisible(iterator.name)) + { + continue; + } + + if (iterator.isArray) + { + ReorderableListGUI.Title(new GUIContent(iterator.displayName, iterator.tooltip)); + ReorderableListGUI.ListField(iterator); + } + else + { + EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); + } } serializedObject.ApplyModifiedProperties(); diff --git a/Assets/Fungus/Flowchart/Scripts/Command.cs b/Assets/Fungus/Flowchart/Scripts/Command.cs index ce7b9171..9f4c126c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Command.cs +++ b/Assets/Fungus/Flowchart/Scripts/Command.cs @@ -166,6 +166,15 @@ namespace Fungus { return Color.white; } + + /** + * Returns true if the specified property should be displayed in the inspector. + * This is useful for hiding certain properties based on the value of another property. + */ + public virtual bool IsPropertyVisible(string propertyName) + { + return true; + } } } \ No newline at end of file