- Home /
Scale menu to fit webplayer with fullscreen on/off
I've probably gone about my GUI the wrong way, I don't know.
I'm using some guiText for my titles, a guiTexture for the background, and OnGUI() to create my buttons. In fullscreen mode everything lines up fine and my intention is that users will play the webplayer in fullscreen, but when not in fullscreen everything gets bunched up.
As far as I know, i've done things in a resolution independent approach: I've used screen co-ordinates and scale set to 0 for my guiTexture, and screen co-ordinates and pixel correct for my guiText. The code i'm using to draw my buttons is as follows (areaWidth and areaHeight are set to 200):
var click : AudioClip; var menuSkin : GUISkin; var areaWidth : float; var areaHeight : float;
function OnGUI () {
GUI.skin = menuSkin;
var ScreenX = ((Screen.width * 0.25) - (areaWidth * 0.5));
var ScreenY = ((Screen.height * 0.5) - (areaHeight * 0.5));
GUILayout.BeginArea(Rect(ScreenX, ScreenY, areaWidth, areaHeight));
if(GUILayout.Button("Level One")){
OpenLevel("instructions");
}
if(captionsPlayed){
if(GUILayout.Button("Level Two")){
OpenLevel("instructions");
}
}
if(visualsPlayed){
if(GUILayout.Button("Level Three")){
OpenLevel("instructions");
}
}
if(GUILayout.Button("Quit")){
Application.Quit();
print("This button works!");
}
GUILayout.EndArea();
}
function OpenLevel(level : String){ audio.PlayOneShot(click); yield WaitForSeconds(0.35); Application.LoadLevel(level);
}
@script RequireComponent (AudioSource)
If someone could clarify how I should be doing this i'd be very grateful. Many thanks.
Been trying to do this too I'll let you know if I find something.
Your answer
Follow this Question
Related Questions
Scaling GUIText + Sharp Fonts 1 Answer
Scale GUITexture to screen resolutions 1 Answer
How-to-make-GUI-Buttons-on-GUI-Texture-resolution-independent 0 Answers
Placing a chat bubble above a character's head in a 3d environment 2 Answers
Bulletproof way to do resolution independant GUI scaling? 2 Answers