- Home /
How to check if selectable is a button?
In my project I have a selectable which stores my current UI selection. Is there an easy way to check if it is a button?
Comment
Answer by Casiell · Nov 20, 2019 at 11:49 AM
You can use pattern matching for that. So your code would look like:
if (selectable is Button button)
{
//"button" variable is your selectable cast to type Button
}
Your answer
Follow this Question
Related Questions
Add Listeners to array of Buttons 2 Answers
HELP how to use buttons 1 Answer
Unity 5: UI button OnPointerDown not function as expected 1 Answer