- Home /
GUI Button not working...but the the script is correct...
I have created the main menu but then a GUI Button problem came up...No errors showing, Button is being displayed...But the button does not work even after many times I have clicked it...Here's the script:
if(isArcadeLambo == true){
GUI.Label(Rect(800, 300, 0, 70), "Speed = 200km/hr", "description");
if(GUI.Button(Rect((Screen.width/2)+560, 470, 0, 70), "Buy for Rs.95,000/-","costButton"))
{
isPlay = true;
levelScript.cash -= 95000;
}
}
All is correct...but it doesn't work..(I have added a new GUI skin for this script, so if its the problem of GUI skin..it's not as I have already checked it...)
If anybody have the solution to this gigantic problem, plz help me... Thanx in advance....
And that script is in an OnGUI call? You've put a Debug.Log just above isPlay = true and it isn't appearing?
In order to trace your problem, have you considered adding a GUI.Label that displays the value of levelScript.cash? It might be helpful to confirm that the button really is doing nothing. You might find that the problem lies elsewhere.
No,the problem doesn't lies elsewhere... I have created a GUI label and it works fine..Only the Button is not acting properly even if it is in On GUI() function and I have added all the textures necessary for a GUI skin...
Can you:
See the button
See a Debug.Log per my suggestion above
I can see the button..But the problem is that it's hover and Active function is not working...So how will Debug.Log work if button can't be clicked...
Answer by V4siliy · Oct 19, 2012 at 12:15 PM
Rect parametrs are: float left, float top, float width, float height.
Your button's width == 0, and maybe problem is in it.
Answer by phodges · Oct 19, 2012 at 12:16 PM
This problem was resolved in the comments: a small error in specifying the control rectangle.
Your answer
Follow this Question
Related Questions
Embed GUI Skin in GUI Button 2 Answers
(4.6 UI) How to set up a window with x buttons, with a scroll bar? 1 Answer
Button Turns Off and On Object 1 Answer
Null reference exception[SOLVED] 1 Answer
Resolutions 1 Answer