|
Hey guys I am new to unity and having a problem with a GUI.toggle. Basically all I want to do is check the value of the GUI.Toggle when I press a button. The problem im having is that the GUI.Toggle value is always false ? even when clicked ? Below is the code cheers to anyone who has insight into the problem
(comments are locked)
|
|
You've declared the variable checkValue, but is toggling chestValue:
public bool checkValue;
void OnGUI()
{
chestValue = GUI.Toggle(new Rect(120, 260, 130, 20), chestValue,"");
}
NOTE: There's a missing left brace after MonoBehaviour: Is this a typo? sorry them the two things you pointed out were typos I'll edit my question to fix these. But the GUI.Toggle is still returning a false value
Apr 20 '12 at 11:28 AM
grady-lad
Well, this should work, unless you're declaring another checkValue inside the function, what would make it a temporary variable and hide the public checkValue. Another thing: public variables appear in the Inspector, which has elephant memory and will always start the game with the value set in the Editor - but the variable should toggle normally at runtime.
Apr 20 '12 at 12:47 PM
aldonaletto
(comments are locked)
|
