diff --git a/Assets/Example/Scenes/Example.unity b/Assets/Example/Scenes/Example.unity index f564160d..2f4d9740 100644 Binary files a/Assets/Example/Scenes/Example.unity and b/Assets/Example/Scenes/Example.unity differ diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs index 3baa99e7..08368c1f 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs @@ -48,8 +48,6 @@ namespace Fungus.Script } } - EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(stepTimeProp, new GUIContent("Step Time", "Minimum time to execute each step")); SequenceEditor.SequenceField(startSequenceProp, diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs index 2c63e227..9082e8b7 100755 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs @@ -132,7 +132,7 @@ namespace Fungus.Script { Sequence sequence = sequences[i]; - float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x; + float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.sequenceName)).x; float windowWidth = Mathf.Max (titleWidth + 10, 100); if (fungusScript.selectedSequence == sequence || @@ -302,7 +302,7 @@ namespace Fungus.Script GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); - GUILayout.Label(sequence.name, labelStyle); + GUILayout.Label(sequence.sequenceName, labelStyle); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); diff --git a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs index 46eed8fd..428d8d22 100644 --- a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs @@ -12,6 +12,15 @@ namespace Fungus.Script [CustomEditor (typeof(Sequence))] public class SequenceEditor : Editor { + SerializedProperty sequenceNameProp; + SerializedProperty descriptionProp; + + void OnEnable() + { + sequenceNameProp = serializedObject.FindProperty("sequenceName"); + descriptionProp = serializedObject.FindProperty("description"); + } + public void DrawSequenceGUI(FungusScript fungusScript) { if (fungusScript.selectedSequence == null) @@ -23,25 +32,10 @@ namespace Fungus.Script Sequence sequence = fungusScript.selectedSequence; - EditorGUI.BeginChangeCheck(); - - string name = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence displayed in editor window"), sequence.name); - string desc = EditorGUILayout.TextField(new GUIContent("Description", "Sequence description displayed in editor window"), sequence.description); - + EditorGUILayout.PropertyField(sequenceNameProp); + EditorGUILayout.PropertyField(descriptionProp); + EditorGUILayout.Separator(); - - if (name != sequence.name) - { - // The name is the gameobject name, so have to undo seperately - Undo.RecordObject(sequence.gameObject, "Set Sequence Name"); - sequence.name = name; - } - - if (desc != sequence.description) - { - Undo.RecordObject(sequence, "Set Sequence Description"); - sequence.description = desc; - } UpdateIndentLevels(sequence); @@ -52,6 +46,7 @@ namespace Fungus.Script if (Application.isPlaying) { + serializedObject.ApplyModifiedProperties(); return; } @@ -81,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()); List commandNames = new List(); @@ -127,6 +123,7 @@ namespace Fungus.Script if (fungusScript.selectedSequence == null || selectedType == null) { + serializedObject.ApplyModifiedProperties(); return; } diff --git a/Assets/Fungus/FungusScript/Scripts/Sequence.cs b/Assets/Fungus/FungusScript/Scripts/Sequence.cs index e5e2117e..d620b286 100644 --- a/Assets/Fungus/FungusScript/Scripts/Sequence.cs +++ b/Assets/Fungus/FungusScript/Scripts/Sequence.cs @@ -15,6 +15,9 @@ namespace Fungus.Script [HideInInspector] public Rect nodeRect = new Rect(10, 10, 100, 40); + [HideInInspector] + public string sequenceName = ""; + [HideInInspector] public string description = "";