How to make GUI.Button disable status?

I want to make some GUI.Button disabled under some condition. I can’t find the right method.

I see GUI.enabled can do this. But how about in case of multiple buttons with their own state? Can each individual GUI.Button be disabled instead of my whole GUI? If so - how?

Thanks.

You can use GUI.Toogle to do so.

Sorry but Toggle can’t. I want full Button feature as normal. But under some condition, it become disabled, and if condition removed, button become activate again and can be used as normal button.

set a boolean.when boolean is true your button will be enable and when false the buttons will be disable.

Thx, but do you mean like:

if(boolean){ 
    if(GUI.Button...)
}

This just erases the Button graphic itself. I want to disable so the disabled Button graphic is on screen but Button is inactive.

GUI.enabled = whatever_determines_the_enabled_status_of_the_button;
if (GUI.Button(args...)) {
    // Button effects
}
GUI.enabled = true;
3 Likes

Thanks!
This work. It was intuitive