- Home /
Duplicate Question http://answers.unity3d.com/questions/781643/unity-46-beta-rect-transform-position-new-ui-syste.html
How do i get the UI button position?
Is it possible to get the button position using script?
How do i get it.
I want to swap two buttons after getting their present position in the screen.
Please Help
Answer by kbumpious · Aug 17, 2015 at 12:31 PM
I would create a temp variable of Vector3 and set:
temp position = button1 position button 1 position = button 2 position button 2 position = temp position
to get 3D position of an object use transform.position to get 1D position of an object use transform.position.x / transform.position.y / transform.position.z
Hope this helped
Answer by Chrisasan · Aug 17, 2015 at 11:58 AM
The transform has the position of all Unity game objects. You want to use something like gameObject.transform.position;
I have never seen a game object in unity that had not transform attached to it. That includes the UnityEngine.UI