Answers for "spawn new object with button unity"

C#
1

unity spawn button

GameObject buttonPrefab;
 
    void MyAwesomeCreator()
    {
        GameObject go = Instantiate(buttonPrefab);
        var button = GetComponent<UnityEngine.UI.Button>();
        button.onClick.AddListener(() => FooOnClick());
    }
    void FooOnClick()
    {
        Debug.Log("Ta-Da!");
    }
Posted by: Guest on November-18-2020

Code answers related to "spawn new object with button unity"

C# Answers by Framework

Browse Popular Code Answers by Language