Browse Source

Show "Create Sequence" when no sequence selected

master
chrisgregan 11 years ago
parent
commit
17f1bb607d
  1. 34
      Assets/Fungus/Editor/FungusScript/CallEditor.cs
  2. 2
      Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs
  3. 43
      Assets/Fungus/VisualScripting/Call.cs

34
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("<Continue>"),
fungusScript,
t.targetSequence);
if (targetSequence != t.targetSequence)
{
Undo.RecordObject(t, "Set Target Sequence");
t.targetSequence = targetSequence;
}
}
}
}

2
Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs

@ -87,7 +87,7 @@ namespace Fungus.Script
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
} }
if (GUILayout.Button("Create", if (GUILayout.Button(t.selectedSequence == null ? "Create Sequence" : "Create",
t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft)) t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft))
{ {
GameObject go = new GameObject("Sequence"); GameObject go = new GameObject("Sequence");

43
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<Sequence> connectedSequences)
{
if (targetSequence != null)
{
connectedSequences.Add(targetSequence);
}
}
public override string GetSummary()
{
if (targetSequence == null)
{
return "<Continue> (No sequence selected)";
}
return targetSequence.name;
}
}
}
Loading…
Cancel
Save