beta 19 - EventSystemManager.currentSystem.IsPointerOverEventSystemObject()

How do I replace this!

I have an in game editor and used this to prevent clicks on the panels from propagating to the game by simply ignoring all input when it was true. In this way any click on a panel could be blocked.

How can I replace this with something that works in the same way?

If i’m understanding your issue your now looking for IsPointOverGameObject() it was rename in b19.

Not really, as that doesn’t seem to do anything useful.
That returns true for everything as I have game objects in the scene. In order to use that I would have to iterate over every object in the scene and determine if one of them was in the ui.

Or maybe you have an example to identify a UI component rather than anything else.

The last function was great, why was it removed!

1 Like

The IsPointerOverEventSystemObject is the same function as IsPointerOverGameObject so it wasnt removed just renamed.

The name maybe still isnt the best as it will only return true for GameObject that the eventsystem hits

I think maybe something is broken then. With the function renamed it no longer behaved in the same way as the previous version.

I resolved the problem with this:

bool IsUIInput()
{

return EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.layer == 5;
}

Hmm did you possibly add a physicsRaycaster to your scene which wasnt present before? as then all gameobjects with a collider would be considered under the pointer.

The only change was to go from beta 17 to beta 19.

I have the exact same problem. I didn’t change anything between beta 18 and 19 in my code but this change caused my UI to break.

This used to work for making sure my UI was clicked on first, and if not then do a physics raycast and hit game objects:

    if (Input.GetMouseButton(0)) {
            if (EventSystemManager.currentSystem.IsPointerOverEventSystemObject()){
                //do something on my UI ONLY
          
            } else {
                //do something else with gameobjects via physics raycast
            }
        }

Using the new IsPointerOverGameObject() in a similar way (with ‘eventSystem’ being a cached object referring to the event system in my scene)

  if (Input.GetMouseButton(0)) {
            if (eventSystem.IsPointerOverGameObject()){
                //no longer works
          
            } else {
                //do something else with gameobjects via physics raycast  * still works*
            }
        }

Now what happens is I get BOTH the UI click and the underlying gameobject click.

interesting I’ll check to see what changed. but could either of you submit a bug so we can track it.

I can do one this evening after I get home from work if freekstorm hasn’t done so by then.

I was doing the same thing in beta18, compiler complained after i updated to beta19 cause of EventSystemManager…
I changed my code to the following:

if ((Physics.Raycast (ray, hit, 100.0)) && Input.GetMouseButtonDown(0) && !eS.IsPointerOverGameObject()) {
… code stuff…
}

and eS declared as a variable like this:
var eS : UnityEngine.EventSystems.EventSystem;

I am setting eS via the Inspector and put in the EventSystem GameObject that gets automatically created in the Scene when building a UI ( so i am refering to the EventSystem script there)

Now it works the same like in beta 18, the UI preventing normal Raycasts to go through.

Hope this helps a bit.

As I’m not at home to test I wonder if this is because you are putting the distance of the raycast (100.0) and the object you are concerned about is farther than that therefore not inducing this problem for you specifically?

@melkior : not sure if i understand this correctly, but my UI is set to Screen.Overlay, therefor always rendered in front and i guess the distance here isnt the issue, i could lower the distance in the raycast as long as its a bit more than the distance between my camera and the gameObject i am testing against.

BUT, before i correctly assigned the eS variable in the inspector i had the same issues with my UI not blocking the raycasts. My guess here is that in your code you are not refering correctly to the Eventsystem. All else is basicly the same in your code.
Have you tried making the eventSystem variable in your code public so you can assign it via inspector?
That was what made it work for me.

Yes that’s exactly how I added it. If you refer to my quoted code I mentioned I had a cached reference to it – that reference came from creating it as a public variable and dragging in via the inspector. (Which I didn’t specifically mention at the time - but clarifying here)

Thats strange, so basically its exactly the same code.
I tested now with the following code in my Update() function:

if (eS.IsPointerOverGameObject()) {
Debug.Log(“Check”);
}

As soon as i move my mouse over an UI Element its writing the “Check” in the Debug.Log Screen - so for me its perfectly working…

Edit:
I tested a bit more:
It seems its only working on Image Elements.
All my UI have Image Elements as backgrounds, as soon as i disable them its not longer working - so hovering over a toggle or a button dont throw a true on the IsPointerOverGameObject anymore, even tough the buttons/toggles have also Image Elements applied.

Seems now like a bug to me.

Interesting … I was specifically having issues with a toggle too. It was the area I was currently designing and testing so I wasn’t poking around the rest of the UI as much.

Its a bit stranger. I tested around with disabling Image Elements, changing hierarchy of the objects in UI etc…
Now i had the same setup like before (No background image, only toggles) and its working correctly.

Maybe its related to some other stuff - i read in another thread that there seems to be issues with changes in the Editor not correctly updated?
Atleast its not always reproducable this way… Sometimes it works, and sometimes not, even tough its the same setup.
Not that much help for your problem tough =(

Well I put together a project to demonstrate the bug and it did not happen in the new project.

So I opened my original project and still have the same problem.

After some testing I found that the original EventSystem that I had dragged in to the script was not present any longer.
So after re-dragging in the EventSystem to the script in the inspector it now works. It’s unclear how the object got disassociated. I suppose it could have happened in the upgrade, or potentially when the change in the script was made from the old “EventSystemManager.currentSystem.IsPointerOverEventSystemObject()” code to the new code? Its unclear at this point.

I was getting a read warning about a missing game object reference, but I had actually another error of the same type I knew about but was going to fix in the near future by re-factoring it out. So essentially by not fixing the other error message the appearance of a new error was not noticed.