my instantiated button will not instantiate a prefab when clicked

Options
my instantiated button will not instantiate a prefab when clicked. i am new to pun and i am trying to get an instantiated button to instantiate an object when clicked. the error i get is "missing prefab reference". i have it assigned in the inspector and when the game is running i can drag and drop the script to the button onclick and it will work. i dont understand why it wont do it without the drag and drop. here is my code. thanks in advance.

// so it will show in the inspector
[SerializeField]
private Button beginButton;

void Start()
{
// i assign it as a game object because i was having trouble not seeing it when the game was running
// so i did this and it becomes a child of the canvas and can be seen and clicked.
GameObject BB = PhotonNetwork.Instantiate(this.beginButton.name, new Vector3(200f,650f,0f),
Quaternion.identity, 0) as GameObject;
BB.transform.SetParent(canvas.transform);

}

Best Answer

  • Yosefxhero
    Answer ✓
    Options
    PhotonNetwork.Instantiate finds the folder named "Resources" and in ur case its gunna look for gameobject named this.beginButton.name.

Answers

  • Yosefxhero
    Answer ✓
    Options
    PhotonNetwork.Instantiate finds the folder named "Resources" and in ur case its gunna look for gameobject named this.beginButton.name.