- Home /
GUI texture to fit the screen at any resolution?
I am trying to add damage to my player, and when he does a GUI texture come up of blood around the edges of the screen, I have my texture but I cannot get it to stay in the place I want it to be in when the resolution changes. I cant really explain any more than this but these pictures should give you a better understanding. Sorry about the external links.
Answer by Eric5h5 · Jan 20, 2013 at 11:49 PM
Make the GUITexture have an X and Y scale of 1.0. Set all pixel inset values to 0. Make sure the X/Y locations are 0.5.
When you mean have the X and Y scale of the texture set to 1 do you mean to set the width and height to 1, or do you mean another way?
I mean set the X and Y scale to 1. Objects have position, rotation, and scale. So, set the X and Y scale to 1. The Z scale is irrelevant.
sorry buddy, not working for me.
i tried as you told, x/y scale to 1 and x/y position to 0.5
but when i choose a relatively big resolution it make texture blurry and very big as compare to screen size.
please guide me, need help :(
$$anonymous$$eep all GUITexture entries as default. Place the GUITexture on an object and use the objects transform to position and size the texture. Works independently of res.
Answer by alok-kr-029 · Sep 24, 2013 at 05:02 AM
Make a plane attach your texture and make it child of ur camera ta da it will work.....
Answer by bernardfrancois · Jan 20, 2013 at 09:58 PM
You may want to use the GUI system instead, by simply calling this in the OnGUI method:
GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), texture);
Answer by niknar · Jan 21, 2013 at 04:34 AM
I do it this way when I use GUITextures for menu backgrounds
public GUITexture MenuBG1; MenuBG1.pixelInset = new Rect(0,0,Screen.width,Screen.height);
That doesn't work so well because you have to check for resolution changes and run the code again if the resolution changes (e.g., player resizes window). Just do what I said and set the x/y scale to 1, then it's always correct with no code.
Your answer
Follow this Question
Related Questions
How to maintain high resolution custom background images for GUI elements on different screen sizes? 0 Answers
Rendering GUI.Buttons in the middle of the screen 5 Answers
Android Screen Resolution 1 Answer
Asset Variations for Different Mobile Screen Sizes 1 Answer
Keeping a GUI texture from moving during change of screen size 2 Answers