Balázs Boros
Balázs Boros

Reputation: 11

Unity UI Canvas selectable buttons

I'd like to add a C# script to my UI Canvas with OnSelect function, but I would like to select which buttons should be affected if I select them. So if I have like 5 buttons under Canvas and I only want to make 2 of them selectable how should I go about it? Any tips?

Upvotes: 0

Views: 1071

Answers (1)

Fattie
Fattie

Reputation: 12287

Sure, it's very easy.

  1. In the Editor look in the Inspector,

enter image description here

you're looking for the "interactable" toggle.

Try "Play" your app in the Editor. When the buttons are visible, try toggling that in the Inspector!

  1. In code, it's easy:

.

yourButton.interactable = false;

or "true". It sounds like you would have five simple Inspector variables for each of your buttons.

public Button b1;
public Button b2;

and so on.

So just b1.interactable = false; and so on.

Upvotes: 2

Related Questions