Laying out Unity menus using GUITexture and GUIText has been a bit confusing.
I'm not entirely sure I understand it yet but the basics are that everything is relative to it's parent.
I've been trying to calculate absolute pixel positions and this has been difficult. Rarely has anything ended up where it was intended.
It wasn't until I read the following post that it sunk in that Unity is trying to scale everything to fit the screen or viewport:
http://answers.unity3d.com/questions/292620/scale-gui-texture-to-current-screen-size.html
As far as I can tell Unity is designed to allow for any resolution on different screen sizes on different platforms. It scales to fit the screen automatically.
If I am doing it manually and Unity is doing it automatically I end up with the wrong result.
I haven't worked it all out myself yet but it might give others reading this a head start if they try to work with the Unity methods rather than bypass them!
==
Follow-up: Since writing the above I have become more confused. If I try to save screen positions in the OnGUI() method to line up with the text or graphic positions on the screen and then process actions based on them in the Update() method I frequently find that the positions are no longer valid.
My results are not consistent. At the moment if I want an input position to line up with text, like processing my own version of a mouse over event, my only reliable solution is to carry out all the processing in the OnGUI() method.
Odd, perhaps someone can tell me why.
Sunday, 19 January 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment