x


Make my HUD full screen

Hello the title says it all. I have a GUITexture and it is transparent in the middle i am using as a HUD. It works fine, but is too small and also, if i build the game and run it on different PC with a different screen size, how can i auto adjust it to fit the screen. Please help, it is greatly appreciated :)

more ▼

asked Dec 30 '11 at 12:00 AM

joeybbb gravatar image

joeybbb
1 2 4 4

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

2 answers: sort voted first

You can use Screen.width and Screen.height to find the screen width and height.

And a PROTIP: Instead of defining controls in a hardcoded way like Rect(10,10,50,50) try the fluidly changeable Rect(screen.width*0.01,screen.height*0.01,screen.width*0.05,screen.height*0.05)

or even the GUILayout class (look in the script reference in [Menu]->[Help]->[Scripting Reference].

more ▼

answered Dec 30 '11 at 01:16 AM

macweirdo gravatar image

macweirdo
41 4 4 6

But where do I edit the size of the GUI Texture? There is only pixel inset, which is location on screen, not size.

Dec 30 '11 at 02:45 AM joeybbb

Sorry, what I meant was: the height and width values dont let me type in letters, only numbers, so how do I type in screen.width etc???

Dec 30 '11 at 11:08 AM joeybbb

You do this via scripting so:

function OnGUI () { //stuff here }

Dec 30 '11 at 03:13 PM macweirdo

Ok thanx. So I havent done any GUI Scripting before do I need to attach the finished script to the GUI Texture or anything in the scene

Jan 01 '12 at 03:17 AM joeybbb

Attach the finished script on any object in the scene. Just remember which one it was.

Jan 01 '12 at 02:53 PM macweirdo
(comments are locked)
10|3000 characters needed characters left

Lets say you position it at the center of a smaller screen. You set the x position as 550 and the y as 550. This is a better solution. Screen.width / 2 for the x and Screen.height / 2 for the y. You might want it a little altered depending on what you use it for. (Screen.width / 2) - 50 for x or something like that.

Hope it helps

more ▼

answered Dec 30 '11 at 12:17 AM

CursedScripter gravatar image

CursedScripter
31 10 13 14

(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
x483
x475
x105
x9

asked: Dec 30 '11 at 12:00 AM

Seen: 1216 times

Last Updated: Jan 02 '12 at 03:36 AM