0

How do i get current pressed UI button on Android. I am using GameObject thisbutton = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;

But i am getting null reference on Andoird logcat. Works fine on editor

sandy
  • 11
  • 1
  • 4

1 Answers1

0

Call this function when the button is pressed

public void ButtonClicked()
   {
       string name = EventSystem.current.currentSelectedGameObject.name;
   }
Muhammad Usama
  • 53
  • 1
  • 12
  • I am already doing this but. It doesnt return the proper pressed button for some reason. For instance if i press button 3, it returns button 5 or button 6 – sandy Sep 17 '21 at 09:38