Browse Source

Use reorderable list for all lists & arrays in command inspector

Added overridable IsPropertyVisible() method to hide specific
properties as needed.
master
chrisgregan 10 years ago
parent
commit
972e69cda4
  1. 18
      Assets/Fungus/Flowchart/Editor/CommandEditor.cs
  2. 9
      Assets/Fungus/Flowchart/Scripts/Command.cs

18
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();

9
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;
}
}
}
Loading…
Cancel
Save