Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

UI.Button won't parent to canvas.

$
0
0
Hi, I have the following code that successfully instantiates a prefab button object. I see the button pop up in the scene-hierachy, but it's way outside the ui canvas coords and it is NOT parented to the canvas (and thus invisible) public Canvas canvas; public GameObject prefabButton; //in start! GameObject gameobject = Instantiate(prefabButton) as GameObject; gameObject.transform.SetParent(canvas.transform, false); gameobject.SetActive(true); While debugging I see that the canvas pointer is set, and is of the type: canvas. Also, I have only one canvas in the scene. Any ideas?

Viewing all articles
Browse latest Browse all 302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>