unity3d - Weird position bug in Unity 4.6 for prefab gameobject as child of Canvas -
i putting prefab (basically image) onto canvas @ "0,0,0" in script (for debug sake). when press play in editor, carried out gameobject end @ "-3.051758e-05,-280,0" i.e. way off 0,0,0. cause this?
the canvas child of root canvas , set max out size in order big parent.
using unity 4.6.
update: not 100% sure yet when setting position using somegameobject.localposition = somevector positioning seems work.
transform.localposition sets position relative parents position whereas transform.position sets position in worldspace. if take @ canvas in scene view see bottom left corner of canvas @ 0, 0, 0 in worldspace, 0, 0, 0 of canvas in center. since have instantiate gameobject first , make child afterwards, it's position in worldspace 0, 0, 0, it's position in inspector position relative parents position , therefor not 0, 0, 0 since canvas doesn't sit 0, 0, 0.
setting child localposition after instantiating position way want relative canvas. 0, 0, 0 in center of game view. position of child in worldspace canvas.x, canvas.y, 0 (you won't see in inspector of course).
Comments
Post a Comment