- Home /
Make button clickable
Hello, i am new in unity.
I am trying to change scene on button click, but its not evening writing log in console. What i am doing wrong?
if(GUI.Button(new Rect(Screen.width * 95 / 100, Screen.height * 15 / 100, 0, 0), "START", customStyle)){
Debug.Log('Start clicked');
menuMode = false;
gameMode = true;
Time.timeScale = 1;
Application.LoadLevel("Scene 1. Beginning");
}
Your button has 0 width and height, I don't know how you are expecting to click it!?
If you are new to Unity. Try using New UI. Here are the tutorials.
stop using the old GUI system you are better of with the new UI
Answer by MobinYaqoob · Apr 23, 2015 at 09:07 PM
Use Unity5.0 UI system it's very easy and helpfull and saves a lot of time.
Answer by Calum1015 · Apr 26, 2015 at 03:39 AM
use var width : float = 10; var height : float = 10; if(GUI.Button(new Rect(Screen.width * 95 / 100, Screen.height * 15 / 100, width, height), "START", customStyle)){ Debug.Log('Start clicked'); menuMode = false; gameMode = true; Time.timeScale = 1; Application.LoadLevel("Scene 1. Beginning");
to start with, you can increase the button size by changing the variables height and width in the inspector
Your answer
Follow this Question
Related Questions
Can't get 4.6 GUI Button to Load Scene (Solved) 1 Answer
GUI Button Disappearing 1 Answer
I have doubt please help me 2 Answers
Unity buttons touchscreen woes 0 Answers