How to Instantiate buttons correctly?
I really have a problem instantiating a Button.
I did the following: I created a button in canvas and added it to prefaps. After that I deleted the button in the Hierachy. I made a Script:
public class ButtonPrefab : MonoBehaviour {
public GameObject buttonPrefab;
GameObject buttonPrefabClone;
void Start() {
buttonPrefabClone = Instantiate(buttonPrefabClone,transform.position,Quaternion.identity) as GameObject;
} }
Finally I created an Empty Object, put the script inside it and added the prefab button.
What I get is a clone button which is WAY out of the canvas and WAY too large. On top of that, I cannot see the Image of the button. I did the exact same thing with a cube prefab and it works perfectly (the cube spawns right there were I put the prefab cube in).
Why doesnt it work? What am I missing?