How to give a relative position to a GUI Texture ?


I'm currently trying to make my game's HUD with GUI Textures and GUI Text.

I have a GUI Texture with the HUD's design, and 3 GUI Text giving pieces of information about the player's state. Quite classic and simple.

First of all, is it right to do it this way ?

I completed the official 3d Platform Tutorial in which a GUI Skin is used, but i thought (and still think) that it's much too complicated for what I want to do.

If it is, how can I give a relative position (depending on width/length of the screen) to my GUI Texture and my GUI Text ?


GUITexture and GUIText objects (as opposed to code in OnGUI functions) use viewport space. This means that (0,0) for the X,Y coordinates is always the lower-left corner of the screen, and (1,1) is always the upper-right corner, no matter what the resolution is.

With respect to your question concerning positioning of GUI components based on screen size, check out the Screen class. You can use its values to set the rectangle position and size. E.g. Screen.width and Screen.height.