Search Unity

EventSystem.current.IsPointerOverGameObject is not working since 5.6

Discussion in 'UGUI & TextMesh Pro' started by Esteban-Gallardo, May 28, 2017.

  1. Esteban-Gallardo

    Esteban-Gallardo

    Joined:
    Feb 19, 2013
    Posts:
    47
    Hi,

    I'm developing a game level edition tool and I was using the function EventSystem.current.IsPointerOverGameObject() to differentiate between clicking on the menus and clicking on the game world. Everything worked smoothly until Unity 5.6 version. Why is this function not working anymore? Are there any plans to fix this critical bug? I'm trying some workaround but they only introduce unexpected problems.

    In case Unity team is not going to fix this issue it would be good to know because to fix it in my project I would have to introduce a week of extra work to recover the original functionality.

    You can check the style of the game editor in these tutorials I made:



    Now, the function IsPointerOverGameObject is always returning "true" no matter where I press.

    Thanks.
     
    Last edited: May 28, 2017
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    It's still working properly for me. Did you recently add a physics raycaster that wasn't there before?

    I don't know if that's the right question to ask you, but I think it could be.

    I have some code that, like you, checks if the pointer is over a gameobject (I use mine only for the UI). This way, dragging panels/sliding sliders, etc.. won't move my camera ;) When I add a physics raycaster to my camera, about 90% of the time, just clicking anywhere and trying to drag "empty space" prevents my camera from moving, because of the code I mentioned.

    If that's not it for you, sorry not sure :)
     
  3. Esteban-Gallardo

    Esteban-Gallardo

    Joined:
    Feb 19, 2013
    Posts:
    47
    Thanks for the help. Yes, you were right. Several weeks ago I did some major change in the in-game UI system and since the game editor shares the same code as the game client some of the code was messing the editor. The solution that I've applied and it's working for me is:

    Code (CSharp):
    1.         if (GameConfig.Mode == GameConfig.MODE_PLAY_LEVEL)
    2.         {
    3.             this.gameObject.GetComponent<GvrPointerPhysicsRaycaster>().enabled = true;
    4.             this.gameObject.GetComponent<PhysicsRaycaster>().enabled = true;
    5.         }
    6.         else
    7.         {
    8.             this.gameObject.GetComponent<GvrPointerPhysicsRaycaster>().enabled = false;
    9.             this.gameObject.GetComponent<PhysicsRaycaster>().enabled = false;
    10.         }
    11.  
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Cool, glad you found a solution :)