Browse Source

Added CallMethod command

master
chrisgregan 10 years ago
parent
commit
659abfba72
  1. 56
      Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs
  2. 12
      Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs.meta

56
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);
}
}
}

12
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:
Loading…
Cancel
Save