diff --git a/Assets/Example/Scenes/Example.unity b/Assets/Example/Scenes/Example.unity index 2f4d9740..e29d0f58 100644 Binary files a/Assets/Example/Scenes/Example.unity and b/Assets/Example/Scenes/Example.unity differ diff --git a/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs b/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs index 0f18df02..e26a96e4 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs +++ b/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; diff --git a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs index 428d8d22..4391f2df 100644 --- a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs +++ b/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());