x


How to Position a GUI at the Top-Right of the Screen?

Title says at all. Need help with this. Thanks!

more ▼

asked Jan 12 '12 at 02:21 AM

UnProj gravatar image

UnProj
1 2 2 3

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

2 answers: sort voted first

first you need to set all transform position xyz to 0 (it makes consistent on window resizing,whatever size is)

then attach script to transform your GUI to top-right pos:

GameObject.Find("YOUR_GUI").guiTexture.pixelInset.y=(Screen.height)-NUMBER; GameObject.Find("YOUR_GUI").guiTexture.pixelInset.x=(Screen.width)-NUMBER;

more ▼

answered Jan 12 '12 at 03:02 AM

eaglemaster7 gravatar image

eaglemaster7
28 5 6 10

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

If you want to display GUI from the function OnGUI, you just need to set your Rect properly, something like "GUI.(GUIElement)( new Rect( Screen.width - W, 0, W, H ), ... );" and then play with W and H; If it's a GUITexture/Text, it's eagleMaster7's answer.

more ▼

answered Jan 12 '12 at 04:39 AM

Berenger gravatar image

Berenger
11k 12 19 53

(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:

x3678
x1946
x885
x786
x80

asked: Jan 12 '12 at 02:21 AM

Seen: 701 times

Last Updated: Jan 12 '12 at 04:39 AM