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 am having the same problem, both on Unity 4 and 5. I set my UI to DontDestroy on load in my initial scene, and then I load the next scene. The UI buttons are there, but they stop working. They no longer highlight when moused over, and they do nothing when clicked. Enabling the buttons before/after loading has no effect either.

The UI needs an EventSystem object to react to events, make sure you have one in your new scene. If you're doing LoadLevelAdditive or marking things to not me destroyed you might be missing the EventSystem.

You are right, i had deleted the Event System. Ty.

event system is present but also no reaction!!!

I have same problem but this solution doesn't work with me.. any help ? I'm stuck here for 6 hours

8 Answers

8

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 specifically logged in just to thank you man. Thank you for this I've tried everything but this? I wouldn't have ever even considered it. Thanks for sharing this info.

oh my god, thank you so much! like the other guy I logged in to thank you, I seriously thought I made the world's weirdest bug as my code was untidy but I couldn't find a reason why it wouldn't work so I googled it thinking I won't find an answer even after reading your comment I thought it wouldn't work.....BUT IT DID, thanks dude!

Dude I could kiss you... I've been searching for a fix for the past 5 days and this was just it... Thank you so much

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

Yup, worked for me. Thanks! :) Still wondering why it's happening though.

I have same problem but this solution doesn't work with me.. any help ? I'm stuck here for 6 hours

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

Sorry can you tell me how did you do that beacause I have the same problem, I have the same standard asset 1st person controller and I have no idea how to do that?

I haven't used that standard asset in awhile, but here is a quick answer I found Googling it. I think you can find the the cursor lock state in the Standard Asset script and just change its true/false value. https://answers.unity.com/questions/1179026/standard-assets-first-person-controller-hiding-cur.html

Just wanted to login and say thank you so much, such a simple thing and I didn't realize it, thank you.

I'm making FPS and when I go back to the title screen the button didn't respond. As you commented, it was because the cursor on the FPS Controller was locked. It was good to be fixed. Thank you!!! 「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.」

I was deleting my Event System this whole time... Thanks for the fix!

Check if your canvas has got proper camera selected.

Here is the solution

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

Thank You kind citizen :D It really worked. I had to put it in the LockCursor method so that will be called whenever pause menu is on

Ur a life saver, thank u so much

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?