How to Deactivate a button unity3d

we have a set of buttons in our game. Each one corresponds to a particular instrument. we have to implement the foll:

a button should become deactivated after being clicked once implying that the same instrument should not be taken twice.

how to accomplish this?

some abstract C# code to represent the idea:

bool clicked = false;

void Button_OnClick()
{
    if( clicked)
        return;

    /* Do action */
    // And perhaps change button texture / colour

    clicked = true;
}

If you use the new UI you are able to change the interactable state of each button. Just add a new event of the “Button”-Component at the inspector. Add a new event with the (+)-icon, drag your Button object in the empty field and select the “No Function” selection box, now you can chooser “Button” → “bool interactable”. If the checkbox isn´t checked the button will not be interactable after clicking.

If you are using the new UI i have made a script. It took me about 30 seconds to figure this out.
Now this code will work for 4 buttons, if you want more its kinda simple.
Now to apply this script make a new empty gameobject doesn’t matter what you call it.
Than add this script. (Its C#)
Then if you have more or less buttons add or remove them from the script(if you need help comment below)
Next on the inspector add all the buttons.
After that Go onto a button and make the onclick function linked to the function on the script. Done

Heres some pictures(in order):
alt text


alt text


alt text
(Yes i even made a GIF of it in action…)

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ActivateButtons : MonoBehaviour {

	public Button Button1;
	public Button Button2;
	public Button Button3;
	public Button Button4;
	float buttonselected = 0;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (buttonselected == 1) {
			Button1.interactable = false;
			Button2.interactable = true;
			Button3.interactable = true;
			Button4.interactable = true;
		}
		if (buttonselected == 2) {
			Button2.interactable = false;
			Button1.interactable = true;
			Button3.interactable = true;
			Button4.interactable = true;
		}
		if (buttonselected == 3) {
			Button3.interactable = false;
			Button1.interactable = true;
			Button2.interactable = true;
			Button4.interactable = true;
		}
		if (buttonselected == 4) {
			Button3.interactable = true;
			Button1.interactable = true;
			Button2.interactable = true;
			Button4.interactable = false;
		}
	}

	public void Button1click(){
		buttonselected = 1;
	}

	public void Button2click(){
		buttonselected = 2;
	}

	public void Button3click(){
		buttonselected = 3;
	}

	public void Button4click(){
		buttonselected = 4;
	}
}