- Home /
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 :)
Answer by macweirdo · Dec 30, 2011 at 01:16 AM
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].
But where do I edit the size of the GUI Texture? There is only pixel inset, which is location on screen, not size.
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???
You do this via scripting so:
function OnGUI () { //stuff here }
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
Attach the finished script on any object in the scene. Just remember which one it was.
Answer by CursedScripter · Dec 30, 2011 at 12:17 AM
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
Your answer
Follow this Question
Related Questions
how to rotate GUI Textures 5 Answers
GUITexture scaling with aspect ratio? 1 Answer
Aligning an overlay to existing GUI elements 0 Answers
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Render Sprite on Screen at 3d game 0 Answers