UI.Button.IsHighlighted <-- How does a guy like me make this work?

I’d like to know if a button is currently selected, so I think the “IsHighlighted” function is proper to use.

But i can’t seem to figure out how to make it work. I’m using UnityScript, and the code below is certainly wrong, but it’s what I’ve got right now. I’m not sure how to put in the event system into the function.

Anyone know?

THANKS!

if (GetComponent(UI.Button).IsHighlighted(eventData : EventSystems.BaseEventData.selectedObject))
print (name + "waspressed");

I have been having the same problem - I would appreciate an answer. When you try to type in IsHighlighted, it does not auto complete in mine. It says it is a protected function - but since you are using an instance of Button that should not matter. Hmm.

1 Like

maybe try something like this

if(gameObject == EventSystem.current.currentSelectedGameObject)  {
   Debug.Log(" we're selected! " );
}
1 Like

Thanks. Yeah, I need to read up more on the EventSystem functionality bc I have no idea how that all works