# Disable a button

**URL:** https://discussions.unity.com/t/disable-a-button/9633
**Category:** Questions & Answers
**Tags:** Scripting, IMGUI
**Created:** [November 5, 2010, 3:24pm UTC](https://discussions.unity.com/t/disable-a-button/9633 "2010-11-05T15:24:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/system/32/97283_2.png) [@system](https://discussions.unity.com/u/system)
#### Post date: [November 5, 2010, 3:24pm UTC](https://discussions.unity.com/t/disable-a-button/9633/1 "2010-11-05T15:24:59Z")

</div>

Hi,I am trying to create a crossword game with 36 buttons with alphabets on them. I want to be able to disable any of these buttons individually when I click on them but I dont know how to achieve this.

---

<div class="post-metadata">

### Author: ![CHPedersen](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@CHPedersen](https://discussions.unity.com/u/CHPedersen)
#### Post date: [August 30, 2011, 7:10pm UTC](https://discussions.unity.com/t/disable-a-button/9633/3 "2011-08-30T19:10:01Z")

</div>

Remember that much of graphics rendering takes place as a state machine… To disable a GUI button, set `GUI.enabled = false` just before drawing it, then set `GUI.enabled = true` right afterwards to re-enable other controls that get drawn after the disabled button.

See documentation for more information.  
 → [Unity - Scripting API: GUI.enabled](http://unity3d.com/support/documentation/ScriptReference/GUI-enabled.html)

All controls drawn with `GUI.enabled = false` will be grayed out and inoperable.

Update with code sample. I had to fill the `string` with the characters with periods, because I don’t know which alphabet has 36 letters. The english one only has 26. Hopefully you get the point.

```auto
Boolean[] BtnEnabled = new Boolean[36];
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ..........";

void OnGUI ()
{
    for( int i=0 ; i<36 ; i++ )
    {
        GUI.enabled = BtnEnabled;
        if( GUILayout.Button(alphabet) )
        {
            _BtnEnabled = false;
        }
        GUI.enabled = true;
    }
}

```

---

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/system/32/97283_2.png) [@system](https://discussions.unity.com/u/system)
#### Post date: [August 30, 2011, 7:11pm UTC](https://discussions.unity.com/t/disable-a-button/9633/4 "2011-08-30T19:11:51Z")

</div>

I asked a similar question before. I didn’t get a perfect solution in here. But I might provide some info that might be helpful.

> **[How to make a Modal Dialog](https://discussions.unity.com/questions/139677/how-to-make-a-modal-dialog.html)**
>
> I know this is been talked many times but I still don't know how to accomplish it. I mean, I've been searching and reading lots of info regarding this topic. But some doesn't work,and some couldn't be understood. I know there's no such internal...
