diff --git a/Assets/Example/Scenes/Example.unity b/Assets/Example/Scenes/Example.unity index afa5300f..3060c85d 100644 Binary files a/Assets/Example/Scenes/Example.unity and b/Assets/Example/Scenes/Example.unity differ diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs index 4004c119..aaaaf52a 100755 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs @@ -24,6 +24,20 @@ namespace Fungus GetWindow(typeof(FungusScriptWindow), false, "Fungus Script"); } + [MenuItem("GameObject/Fungus/Fungus Script")] + static void CreateFungusScript() + { + GameObject newFungusScriptGO = new GameObject(); + newFungusScriptGO.name = "FungusScript"; + FungusScript fungusScript = newFungusScriptGO.AddComponent(); + GameObject newSequenceGO = new GameObject(); + newSequenceGO.transform.parent = newFungusScriptGO.transform; + newSequenceGO.name = "Start"; + newSequenceGO.hideFlags = HideFlags.HideInHierarchy; + Sequence sequence = newSequenceGO.AddComponent(); + fungusScript.startSequence = sequence; + } + // Implementing this method causes the padlock image to display on the window // https://leahayes.wordpress.com/2013/04/30/adding-the-little-padlock-button-to-your-editorwindow/#more-455 void ShowButton(Rect position) { @@ -137,8 +151,8 @@ namespace Fungus for (int i = 0; i < sequences.Length; ++i) { Sequence sequence = sequences[i]; - - float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.sequenceName)).x; + + float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x; float windowWidth = Mathf.Max (titleWidth + 10, 100); if (fungusScript.selectedSequence == sequence || @@ -310,7 +324,7 @@ namespace Fungus GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); - GUILayout.Label(sequence.sequenceName, labelStyle); + GUILayout.Label(sequence.name, labelStyle); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); diff --git a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs index 88061569..c3a0690b 100644 --- a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs @@ -17,7 +17,6 @@ namespace Fungus void OnEnable() { - sequenceNameProp = serializedObject.FindProperty("sequenceName"); descriptionProp = serializedObject.FindProperty("description"); } @@ -31,8 +30,15 @@ namespace Fungus serializedObject.Update(); Sequence sequence = fungusScript.selectedSequence; - - EditorGUILayout.PropertyField(sequenceNameProp); + + EditorGUI.BeginChangeCheck(); + string sequenceName = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence object"), sequence.gameObject.name); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(sequence.gameObject, "Set Sequence Name"); + sequence.gameObject.name = sequenceName; + } + EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.Separator(); @@ -183,7 +189,7 @@ namespace Fungus Sequence[] sequences = fungusScript.GetComponentsInChildren(); for (int i = 0; i < sequences.Length; ++i) { - sequenceNames.Add(new GUIContent(sequences[i].sequenceName)); + sequenceNames.Add(new GUIContent(sequences[i].name)); if (sequence == sequences[i]) { @@ -221,7 +227,7 @@ namespace Fungus Sequence[] sequences = fungusScript.GetComponentsInChildren(); for (int i = 0; i < sequences.Length; ++i) { - sequenceNames.Add(new GUIContent(sequences[i].sequenceName)); + sequenceNames.Add(new GUIContent(sequences[i].name)); if (sequence == sequences[i]) { diff --git a/Assets/Fungus/FungusScript/Scripts/Sequence.cs b/Assets/Fungus/FungusScript/Scripts/Sequence.cs index e4c1b66e..44a4cfa6 100644 --- a/Assets/Fungus/FungusScript/Scripts/Sequence.cs +++ b/Assets/Fungus/FungusScript/Scripts/Sequence.cs @@ -14,8 +14,6 @@ namespace Fungus { public Rect nodeRect = new Rect(10, 10, 100, 40); - public string sequenceName = "Sequence"; - public string description = ""; [System.NonSerialized]