I am trying to Instantiate a prefab panel as a child of another panel, but it is not appearing where I am expecting it. I feel like I must be missing a step somewhere.
GameObject panelAtk = GameObject.Find("Show Stats Panel Atk");
GameObject inputHowManyPrefab = Resources.Load("Prefabs/How Many Panel", typeof(GameObject)) as GameObject;
GameObject inputHowMany = Instantiate(inputHowManyPrefab, inputHowManyPrefab.transform.position, inputHowManyPrefab.transform.rotation, panelAtk.transform) as GameObject;
I was expecting something like this:
The cloned prefab shows up in the hierarchy correctly, but at the wrong coordinates:
The prefab’s rect transform looks like this:
Left Top Pos Z
9.8 210 0
Right Bottom
10.2 11
… but the Instantiated panel’s transform is not even close.
Left Top Pos Z
-365.2324 547.1365 0
Right Bottom
385.2324 -318.1365
Any idea as to what I am missing?
Thanks.