diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs new file mode 100644 index 00000000..48715808 --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs @@ -0,0 +1,56 @@ +using UnityEngine; +using System.Collections; + +namespace Fungus +{ + // This command is called "Call Method" because a) it's more descriptive than Send Message and we're already have + // a Send Message command for sending messages to trigger block execution. + + [CommandInfo("Scripting", + "Call Method", + "Calls a named method on a GameObject using the GameObject.SendMessage() system.")] + [AddComponentMenu("")] + public class CallMethod : Command + { + [Tooltip("Target monobehavior which contains the method we want to call")] + public GameObject targetObject; + + [Tooltip("Name of the method to call")] + public string methodName = ""; + + public override void OnEnter() + { + if (targetObject == null || + methodName.Length == 0) + { + Continue(); + return; + } + + targetObject.SendMessage(methodName, SendMessageOptions.DontRequireReceiver); + + Continue(); + } + + public override string GetSummary() + { + if (targetObject == null) + { + return "Error: No target GameObject specified"; + } + + if (methodName.Length == 0) + { + return "Error: No named method specified"; + } + + return targetObject.name + " : " + methodName; + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs.meta b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs.meta new file mode 100644 index 00000000..9fcfbe29 --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 17a200dbd67304446a3019434503338a +timeCreated: 1430927467 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: