diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs index 48715808..8f2ff717 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs @@ -18,6 +18,9 @@ namespace Fungus [Tooltip("Name of the method to call")] public string methodName = ""; + [Tooltip("Delay (in seconds) before the method will be called")] + public float delay; + public override void OnEnter() { if (targetObject == null || @@ -27,11 +30,23 @@ namespace Fungus return; } - targetObject.SendMessage(methodName, SendMessageOptions.DontRequireReceiver); + if (delay == 0f) + { + CallTheMethod(); + } + else + { + Invoke("CallTheMethod", delay); + } Continue(); } + protected virtual void CallTheMethod() + { + targetObject.SendMessage(methodName, SendMessageOptions.DontRequireReceiver); + } + public override string GetSummary() { if (targetObject == null)