如何创建一个可以 select 场景 > 脚本 > 函数中的对象的自定义检查器 (public void...)

How to create a custom inspector which can select object in scene > script > function (public void...)

我的用户能够 select 一个对象,然后是一个脚本,然后是脚本中的一个 void。

所以基本上,在 script1 的检查器中,我希望用户能够 select 一个对象,然后是其中的一个脚本,然后是一个空的脚本。

玩家必须 select 的功能与 UI 按钮相同。

自己为 Inspector 实现这样一个 Drawer 需要思考并且相当复杂(参见source code of UnityEventDrawer)。


无论如何,我猜你实际上是在谈论在你的脚本中简单地使用你自己的UnityEvent (That's exactly what the Button.onClick用途),例如

public class Example : MonoBehaviour
{
    public UnityEvent OnSomethingHappened;

    // And invoke it where needed
    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space)) OnSomethingHappened?.Invoke();
    }
}