1
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ Hello and welcome to Gamedev.SE! What have you tried? \$\endgroup\$
    – Katu
    Apr 22, 2015 at 11:17

2 Answers 2

1
\$\begingroup\$
if(Input.GetMouseButtonUp(0))
this.gameObject.SetActive(false);

This will hide the "button" completely from your scene until you decide otherwise.

I recommend you go through the docs so you can figure out these answers by yourself.

\$\endgroup\$
1
\$\begingroup\$

If you use Unity superior or equal to 4.6, you can use UI/Selectable-interactable.

The button will cannot be used if interactable is set to false.

For example:

public Button instrumentButton;

void Update ()
{
    if (canPlayInstrument == false)) {
        instrumentButton.interactable = false;
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .