x


How to give a relative position to a GUI Texture ?

Hi,

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 ?

Thanks!

more ▼

asked May 30 '10 at 06:12 PM

Wizz gravatar image

Wizz
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered May 30 '10 at 09:28 PM

Eric5h5 gravatar image

Eric5h5
80.2k 41 132 519

I just tried it out and my HUD fits to the screen, no matter the resolution (as you said). Thank you!

May 30 '10 at 10:29 PM Wizz
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered May 30 '10 at 08:08 PM

SteveFSP gravatar image

SteveFSP
1k 8 13 29

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3680
x2196
x885
x83

asked: May 30 '10 at 06:12 PM

Seen: 3113 times

Last Updated: May 30 '10 at 06:12 PM