NullReference Exception when switching to a new scene

Continuing the discussion from Error after completing Cursor Lectures [HELP]:

I think I have the same issue mschoenhals has.
Sadly the solution was not shared :frowning:

When I move into a portal and the game loads a new scene, I get tons and tons of NullReference Exceptions:

NullReferenceException: Object reference not set to an instance of an object
RPG.Control.PlayerController.HandleUI () (at Assets/Scripts/Control/PlayerController.cs:67)
RPG.Control.PlayerController.Update () (at Assets/Scripts/Control/PlayerController.cs:45)

private bool HandleUI()
{
if(EventSystem.current.IsPointerOverGameObject()) // only refers to UI! not to other elements in the world
{
SetCursor(CursorType.UI);
return true;
}
return false;
}

the offending line being the if statement.

Scene 0 (working)

Scene 1 (broken)

I did some more digging. It definitely is the if statement itself that is causing the issue.
not the body, the statement itself.
EventSystem.current.IsPointerOverGameObject() seems to run into an issue…

Found the solution.
The EventSystem object was missing in the other scene.

Had to add it again:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms