- Home /
Question by
YosephWordofa · Dec 29, 2020 at 03:58 AM ·
uiinstantiatecanvasrecttransform
Instantiating UI element on Screen space - Overlay not instantiating exact specified location
I am trying to Instantiate a RectTransform on a canvas under a specific parent as child in that parents exact location. (I just want to use the parent as the reference to instantiate the new UI element)
I am using this during Start to instantiate the UI element.
public RectTransform theNewSpawn_prefab; //the UI element needed for Instantiation on start
var HUDobj = Instantiate(theNewSpawn_prefab, Vector3.zero, Quaternion.identity, parentLocation);
I have successfully Instantiated the element as a child of "parentLocation", However it never gets positioned at the exact location of the parent. it's always off by some units sometimes even off the canvas size (only happens when I move the parent to the location I want the element to be).
And this happens mostly when i work with Screen space - Overlay, Screen space - Camera seems to work ok. not sure how to fix.
any help is appreciated, thank you!
Comment