Browse Source

replaced say dropdown menu with object picker

master
Timothy Ng 9 years ago
parent
commit
74c14f5985
  1. 6
      Assets/Fungus/Flowchart/Editor/CommandEditor.cs
  2. 7
      Assets/Fungus/Narrative/Editor/SayEditor.cs

6
Assets/Fungus/Flowchart/Editor/CommandEditor.cs

@ -154,6 +154,7 @@ namespace Fungus
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
static public void ObjectField<T>(SerializedProperty property, GUIContent label, GUIContent nullLabel, List<T> objectList) where T : Object static public void ObjectField<T>(SerializedProperty property, GUIContent label, GUIContent nullLabel, List<T> objectList) where T : Object
{ {
if (property == null) if (property == null)
@ -172,14 +173,16 @@ namespace Fungus
if (objectList[i] == null) continue; if (objectList[i] == null) continue;
objectNames.Add(new GUIContent(objectList[i].name)); objectNames.Add(new GUIContent(objectList[i].name));
if (selectedObject == objectList[i]) if (selectedObject == objectList[i])
{ {
selectedIndex = i + 1; selectedIndex = i + 1;
} }
} }
T result; T result;
selectedIndex = EditorGUILayout.Popup(label, selectedIndex, objectNames.ToArray()); selectedIndex = EditorGUILayout.Popup(label, selectedIndex, objectNames.ToArray());
if (selectedIndex == 0) if (selectedIndex == 0)
{ {
@ -192,6 +195,7 @@ namespace Fungus
property.objectReferenceValue = result; property.objectReferenceValue = result;
} }
/** /**
* When modifying custom editor code you can occasionally end up with orphaned editor instances. * When modifying custom editor code you can occasionally end up with orphaned editor instances.

7
Assets/Fungus/Narrative/Editor/SayEditor.cs

@ -111,17 +111,14 @@ namespace Fungus
{ {
DestroyImmediate(blackTex); DestroyImmediate(blackTex);
} }
public override void DrawCommandGUI() public override void DrawCommandGUI()
{ {
serializedObject.Update(); serializedObject.Update();
bool showPortraits = false; bool showPortraits = false;
CommandEditor.ObjectField<Character>(characterProp, characterProp.objectReferenceValue = (Character) EditorGUILayout.ObjectField(characterProp.objectReferenceValue, typeof(Character), true);
new GUIContent("Character", "Character that is speaking"),
new GUIContent("<None>"),
Character.activeCharacters);
Say t = target as Say; Say t = target as Say;

Loading…
Cancel
Save