Browse Source

Converted FungusVariableListAdapter to use SerializedProperty

master
chrisgregan 11 years ago
parent
commit
33397f004f
  1. BIN
      Assets/Example/Scenes/Example.unity
  2. 20
      Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs
  3. 1
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

BIN
Assets/Example/Scenes/Example.unity

Binary file not shown.

20
Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs

@ -201,20 +201,20 @@ namespace Fungus.Script
}
else
{
EditorGUI.BeginChangeCheck();
key = EditorGUI.TextField(keyRect, variable.key);
GUI.Label(valueRect, type);
scope = (VariableScope)EditorGUI.EnumPopup(scopeRect, variable.scope);
if (EditorGUI.EndChangeCheck ())
{
Undo.RecordObject(variable, "Set Variable");
// Modify the key if it clashes with an existing variable key
variable.key = fungusScript.GetUniqueVariableKey(key, variable);
variable.scope = scope;
}
// To access properties in a monobehavior, you have new a SerializedObject
// http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html
SerializedObject variableObject = new SerializedObject(this[index].objectReferenceValue);
SerializedProperty keyProp = variableObject.FindProperty("key");
SerializedProperty scopeProp = variableObject.FindProperty("scope");
variableObject.Update();
keyProp.stringValue = fungusScript.GetUniqueVariableKey(key, variable);
scopeProp.enumValueIndex = (int)scope;
variableObject.ApplyModifiedProperties();
}
GUI.backgroundColor = Color.white;

1
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -76,6 +76,7 @@ namespace Fungus.Script
GUILayout.Label("New Command");
GUILayout.FlexibleSpace();
// We should probably use SerializedProperty for the category & command index but there's no real benefit to doing so
int selectedCategoryIndex = EditorGUILayout.Popup(fungusScript.selectedCommandCategoryIndex, categories.ToArray());

Loading…
Cancel
Save