- Home /
Different UI coordinates
Hello community!
I have a code that stores UI start position:
void Start () {
startpos = transform.position;
}
But the problem is that inspector coordinates and startpos coordinates are different.
For example, if inspector coordinates are: x:85, y:-310. then startpos coordinates are x:85, y:125.
My UI settings are: :
Any help would be highly appreciated.
Answer by fafase · Mar 20, 2015 at 08:49 PM
The UI setting is confusing, that is because positions, anchors and all size delta are related to parent and pivot point. Once you get the idea, it tends to be easier to understand but not to figure out anyway.
Nonetheless, you can still get the position as used to via basic transform. Those will be some larger values than usual. This is due to the fact that the Canvas is also rendered in world space, see the gigantic white rectangle representing the UI in the scene. Origin is bottom left.
Try this to see it:
public class Test: MonoBehaviour
{
public Vector3 position;
private RectTransform rt;
void Start()
{
rt = GetComponent<RectTransform>();
}
void Update()
{
rt.position = position;
}
}
Give some values to the vector as you run the game.
Thanks for revealing my doubts, i was wondering if i have done something wrong :)
Your answer

Follow this Question
Related Questions
[CANVAS] Coordinate transfer with scaling (pictures+details) 2 Answers
Creating Minimap Issues 0 Answers
UI issue: Getting screen coordinates from a World Space object 1 Answer
Gui point to world position 1 Answer
UI Text In Seconds 2 Answers