Question by
greatjulius · Sep 14, 2015 at 04:45 PM ·
2dscripting problemguibuttonlevel load
Trouble with GUI Button Level switching.
Hi,
i wrote a simple script for a button that (when it gets clicked) changes the current Scene. Here is a part of it:
void OnGUI()
{
//Display TitleScreen
GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), TitleScreen);
//Display Buttons
if (GUI.Button (new Rect (Screen.width * .37f, Screen.height * .34f, Screen.width * .25f, Screen.height * .1f),"",Button1));
{
Application.LoadLevel(1);
}
I tested it but if i start the game the level switches immediately. I didn't clicked it. If i start the game the scene just switches in the moment the GUI Button loaded. I don't know what is wrong there.
Comment
Your answer
Follow this Question
Related Questions
How to create GUI BUTTON from this 1 Answer
how can I open url link in Unity/Vuforia android app 2 Answers
Script to animation and movement of 2d player 1 Answer
Input/Animation works fine in Play (Editor) but not in the build 0 Answers
how to make a button make an image show inside another button 1 Answer