Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使我在检查员中选择了我要使用的方法?_C#_Unity3d - Fatal编程技术网

C# 如何使我在检查员中选择了我要使用的方法?

C# 如何使我在检查员中选择了我要使用的方法?,c#,unity3d,C#,Unity3d,脚本有两种方法。如何使我在检查员中选择我要使用的方法 public void PrintHello() { Debug.Log("Hello"); } public void PrintHowAreYou() { Debug.Log("How are you?"); } 我写的这些方法就是一个例子。您可以使用它从编辑器检查器选项卡中选择一个函数 声明如下: public UnityEvent method; 从编辑器中,您可以选择该脚本附加到的游戏对象、脚本名称以及函数 如

脚本有两种方法。如何使我在检查员中选择我要使用的方法

public void PrintHello()
{
    Debug.Log("Hello");
}

public void PrintHowAreYou()
{
    Debug.Log("How are you?");
}
我写的这些方法就是一个例子。

您可以使用它从编辑器检查器选项卡中选择一个函数

声明如下:

public UnityEvent method;
从编辑器中,您可以选择该脚本附加到的游戏对象、脚本名称以及函数

如果需要调用该方法,则很容易做到:

void Start()
{
    method.Invoke();
}

非常感谢!不客气。不要忘记通过点击左侧的复选标记图像来接受这个答案。有关更多信息,请参阅帖子