You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
10 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|