public createButton() { MyButtonScript newButton = (MyButtonScript )Instantiate(myNguiButtonPrefab); newButton.name = "newButton" + (nextId++); newButton.Setup(/* some parameters */); }
public createButton(){ GameObject newButton = (GameObject)Instantiate(myNguiButtonPrefab); newButton.name = "newButton" + (nextId++); MyButtonScript buttonScript = newButton.GetComponent<MyButtonScript>(); buttonScript.Setup(/* some parameters */); }