Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created March 12, 2016 08:46
Show Gist options
  • Select an option

  • Save unitycoder/bfbaa501a7ddc71dbe6a to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/bfbaa501a7ddc71dbe6a to your computer and use it in GitHub Desktop.
Get Selected UI GameObject with EventSystem
using UnityEngine;
using UnityEngine.EventSystems;
public class GetCurrentUIObject : MonoBehaviour
{
void Update()
{
// prints Null if nothing is selected, or name of the gameobject
Debug.Log(EventSystem.current.currentSelectedGameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment