diff --git a/Assets/Fungus/Editor/FungusScript/CallEditor.cs b/Assets/Fungus/Editor/FungusScript/CallEditor.cs new file mode 100644 index 00000000..9c9ee618 --- /dev/null +++ b/Assets/Fungus/Editor/FungusScript/CallEditor.cs @@ -0,0 +1,34 @@ +using UnityEditor; +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace Fungus.Script +{ + + [CustomEditor (typeof(Call))] + public class CallEditor : FungusCommandEditor + { + public override void DrawCommandGUI() + { + Call t = target as Call; + + FungusScript fungusScript = t.GetFungusScript(); + if (fungusScript == null) + { + return; + } + + Sequence targetSequence = SequenceEditor.SequenceField(new GUIContent("Target Sequence", "Sequence to call"), + new GUIContent(""), + fungusScript, + t.targetSequence); + if (targetSequence != t.targetSequence) + { + Undo.RecordObject(t, "Set Target Sequence"); + t.targetSequence = targetSequence; + } + } + } + +} diff --git a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs index 70ad5704..a293f425 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs @@ -87,7 +87,7 @@ namespace Fungus.Script GUILayout.FlexibleSpace(); } - if (GUILayout.Button("Create", + if (GUILayout.Button(t.selectedSequence == null ? "Create Sequence" : "Create", t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft)) { GameObject go = new GameObject("Sequence"); diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/Call.cs new file mode 100644 index 00000000..12fae471 --- /dev/null +++ b/Assets/Fungus/VisualScripting/Call.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace Fungus.Script +{ + [HelpText("Execute another sequence.")] + public class Call : FungusCommand + { + public Sequence targetSequence; + + public override void OnEnter() + { + if (targetSequence != null) + { + ExecuteSequence(targetSequence); + } + else + { + Continue(); + } + } + + public override void GetConnectedSequences(ref List connectedSequences) + { + if (targetSequence != null) + { + connectedSequences.Add(targetSequence); + } + } + + public override string GetSummary() + { + if (targetSequence == null) + { + return " (No sequence selected)"; + } + + return targetSequence.name; + } + } + +} \ No newline at end of file