UI Buttons Stop Working After I Load Another Scene And Then Come Back

Hi,

I have a game over scene and i have 2 buttons (which i created using the new UI menu, i did’t create them using script), a restart button and an end game button.

When i create the buttons and i add the OnClick function they work fine, but if i load a different scene and then come back to the game over scene they stop working, they don’t even change colors when i hover over them or i press them.

I might know what is wrong. Add:

void Start ()
{
    Time.timeScale = 1;
}

Your game might have been paused to zero, and I don’t know why Unity keeps the timescales… sometimes…

I had same problem just solved it by setting “Force module Active” @Event System

Tried all of these and didn’t fix it. Finally found my problem:

I’m using the standard 1st person controller asset, and it locks the cursor. Need to unlock the cursor when going back to the main menu.

In the past I have had:

  1. UI textbox/image is on top of button so it isn’t clickable
  2. DontDestroyOnLoad doing wonky things
  3. Accidentally deleting the “Event System” GameObject in your scene (maybe mispelled it) that handles things like buttons being clicked.

Cheers

Check if your canvas has got proper camera selected.

Here is the solution

void Awake()
{
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
}

In my case the issue was that the buttons were in a WorldSpace canvas, and as I was changing scenes while maintaining the same camera, Unity didn’t know to properly connect between the Canvas and the Camera, until the camera was tagged as “MainCamera”.

I found the solution through this thread:

Just logging to help the developers, i have the same issue here, two scenes, the UI works well in the first scene, but the UI does not work in the second. Just copy the “Event System” component from the hierarchy of first scene to the second, worked for me :slight_smile:

Tried with “Force module Active” also Time.timeScale = 1; and even created a preload scene for the DontDestroyOnLoad objects, still no luck. I can click the UI Canvas elements at the editor however cant click at the device after reloading menu that has NetworkManager

Anyone has an idea?