Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Check whether touch is interacting with new interface?

Discussion in 'UGUI & TextMesh Pro' started by _Adriaan, Nov 8, 2014.

  1. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Hi there!

    I occasionally have the problem that while the player is interacting with the in-game overlay, the clicks and touches also reach the game world and interact with that gameworld.

    How can I avoid this? Can anyone point me into a direction in which I can check whether I'm currently touching the interface?

    Thanks a bunch!!
     
  2. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    So... there's nothing for this? Does this mean that every button in my in-game overlay will also have to cancel every interaction with the game world?
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    a quick search of the forums will lead you to the answer. EventSystemManager.currentSystem.IsPointerOverEventSystemObject()
     
  4. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    I did, but if you don't know what to look for it's pretty difficult to find something this specific. For instance, the fact that this function has 'pointer' in the name is confusing in the context of a game for mobile touch screens.

    Anyway, thanks Phil.
     
  5. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Just a heads up - it seems like a bunch of things got renamed, am I correct? It now seems to be:

    Code (CSharp):
    1. EventSystem.current.IsPointerOverGameObject(int pointerId);
    Also, what is the pointerId parameter?
     
  6. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Code (CSharp):
    1. if (EventSystem.current.IsPointerOverGameObject())
    2.     Debug.Log("OVER");
    3. else
    4.     Debug.Log("NOT OVER");
    Why doesn't this work?
     
  7. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    need more context.