📜  unity spawn 按钮 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:56.185000             🧑  作者: Mango

代码示例1
GameObject buttonPrefab;
 
    void MyAwesomeCreator()
    {
        GameObject go = Instantiate(buttonPrefab);
        var button = GetComponent();
        button.onClick.AddListener(() => FooOnClick());
    }
    void FooOnClick()
    {
        Debug.Log("Ta-Da!");
    }