Position UI - Rect and Vector2

Hi,

I have a big problem with aspect proportion (monitor). I made a GUI text with GUI.Label, and when I change the proportion of the screen it Works fine.
And when I made a UI object and change the monitor proportion the object change the proportional position, different to GUI.Label. Why that’s happend? How can I fix this problem?
You can see that I’m set the position value based on monitor size.

private void OnGui(){
        GUI.Label(new Rect(Screen.width / 2 + 1, Screen.height / 1.20f + 1, size.x, size.y), "TESTING", subtitleStyle);

//barTime is a simple GameObject that is a child from Canvas
            barTime.GetComponent<RectTransform>().anchoredPosition = new Vector2(Screen.width/ -2 + 160, Screen.height/-2 - 80);

}

PS: Sorry about my english.

It looks like you just need some anchoring tweaks. Check out the Ray Wenderlich UI tutorial, it explains a lot of this. It is tricky but it is pretty powerful.

1 Like

You’re completely right. Thank you so much, you solved a problem that took me all day.