- Home /
Display not the same as expected
I would like to ask regarding the display problem.
I try running my games on the Unity web player, but some of the display are not shown as what it is expected. For example the guiText, it is different from the editor and the webplayer. Another issue is the onGUI, how come it will display differently. I do not know whether i did explain clearly what i want to ask. But overall, i want to know what can i do to make sure that everything display according to what i expected it to be. Like the guiText, OnGUI, guiTexture etc.
Thank you and sorry for the poor explanation
hello. Yes. I think is the resolution problem. For example, this guiText is supposedly to be display in the center, but when it run on webplayer, it is at the top left corner.
Answer by Chris 26 · Jan 25, 2012 at 05:17 PM
I guess your problem is that you just take numbers like
x = 100, y = 50
for the positioning, instead you should use "Screen.width" and "Screen.height", to make sure a change of screen resolution does not destroy your layout.
For example
GUI.Box (new Rect (Screen.width/2,Screen.height/2,100,50));
you can also multiply the width and height of the box or an offset with Screen.width and height if you want that it scales with the resolution.
yes. i did it that way. GUI.Window(0, Rect((Screen.width/2)-10, (Screen.height/2)-150, 330, 240), showDetails, "How To Play Click && $$anonymous$$atch!!!");
But my guiText i edit the position through the inspector. How am i going to solve it??
Not sure if I got what you want but if you mean you want to edit the position of the guiText in the inspector you just need to declare yourself variables like
float offsetX; float offsetY;
then you write
GUI.Window(0, Rect((Screen.width/2)+offsetX, (Screen.height/2)+offsetY, 330, 240), showDetails, "How To Play Click && $$anonymous$$atch!!!");
and then you need to set the variables in the inspector, you can do the same for the width and the height of the button. Hope that was what you wanted to know.
Your answer

Follow this Question
Related Questions
How to make buttons in scene view? 1 Answer
Make a Button out of a Textured Plane 2 Answers
GUI Textures problem 1 Answer
blood splatter 3 Answers
Integrating CefSharp into Unity 0 Answers