I created a start with some pictures on it and a slider where the player can adjust the difficulty of the game. After that I use Application.LoadLevel to start the game. There are two strange things happening, when I klick on the start button:
- The slider switches to the center automatically
- The new scene is only loades after the second click on the button.
Here is the code:
function OnGUI ()
{
screenW = Screen.width;
screenH = Screen.height;
var positionRect = Rect(screenW*0.5-screenW*0.25-easy.width*screenH*0.1/easy.height, screenH*0.5,easy.width*screenH*0.2/easy.height,screenH*0.2);
//GUI.Box (Rect(0,0,screenW,screenH),""); //block other interactions with a full screen box
GUI.DrawTexture(Rect(20,20,screenW-40,titleScreen.height*(screenW-40)/titleScreen.width),titleScreen, ScaleMode.StretchToFill,true,0);
GUI.DrawTexture(positionRect,easy, ScaleMode.StretchToFill,true,0);
positionRect.center.x = screenW*0.5;
positionRect.width =middle.width*screenH*0.2/middle.height;
GUI.DrawTexture(positionRect,middle, ScaleMode.StretchToFill,true,0);
positionRect.center.x = screenW*0.75;
positionRect.width =hard.width*screenH*0.2/hard.height;
GUI.DrawTexture(positionRect,hard, ScaleMode.StretchToFill,true,0);
difficulty = GUI.HorizontalSlider (Rect (screenW*0.5-screenW*0.25, screenH*0.7, screenW*0.5, screenW*0.125), difficulty, 50.0, 5.0);
if (GUI.Button(Rect(screenW*0.5-screenH*0.1,screenH*0.8,screenH*0.2,screenH*0.2),startIcon))
{
Application.LoadLevel("MainScene");
}
//GameObject.Find("MainControllerObject").GetComponent.<MathScript>().difficulty = difficulty;
}
Any ideas?
asked
Aug 08 '12 at 07:16 AM
fschaar
40
●
6
●
9
●
16