Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

When does EventSystem.current.IsPointerOverGameObject return true?

Discussion in 'UGUI & TextMesh Pro' started by cado82, Dec 11, 2020.

  1. cado82

    cado82

    Joined:
    Jul 29, 2020
    Posts:
    25
    I'm using unity 2020.1.14f1. When does this function return true and when does it return false? The documentation says "Is the pointer with the given ID over an EventSystem object?". Can anyone tell me what an EventSystem object is in this context?
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    This may be the wrong sub-forum, since EventSystem is a class from the UGUI (Unity 4.6 UI system). In that system, the EventSystem is a component on a GameObject in the scene. It manages input events and navigations, such as which GameObject is considered selected or where the mouse is currently hovering over. In your specific case, IsPointerOverGameObject will return true, when the EventSystem thinks that the pointer is hovering any GameObject that is registered by any of the raycasters in the system. For example, Graphic Raycaster checks for raycast target within a Canvas hierarchy, Raycaster 2D sends 2D raycast into the scene and can detect BoxCollider2D for example and there's a version for 3D as well. Any of these objects, which can be detected by the EventSystem, may be considered "EventSystem objects" although I don't think this terminology is used often.