- Home /
Canvas Buttons not working after LevelLoad
I made a UI in the new canvas system. The canvas is placed in the Menu screen and made into an Unity-Singleton with DontDestroyOnLoad(true). The canvas uses the "Screen Space - Camera" option.
While in menu screen everything works perfectly - the buttons get highlighted when hovered and can be clicked. After loading a new Level the buttons do not work anymore. They don't react on hovering or clicks. There was no change done to the canvas while switching the level and I have no idea what is causing this trouble.
EDIT: I found a fix: somehow there was no eventsystem attached to the canvas, adding this made it work. But I still want to know why. Why does it work without the eventsystem in the first scene and not in the second one?
Greetings, lactus
Answer by Kiwasi · Dec 14, 2014 at 02:08 AM
You need one event system somewhere in your screen for the UI to work. Typically it should be on its own GameObject.
When you create a canvas the event system gameobject is created for you automatically.
I had this same issue and forgot about the event system im parented it to my canvas and I have no problems anymore thanks.
On a side note the person who asked this question if its a solved issue please mark the answer correct.
It's also worth noting that if you somehow have 2 event systems in your scene the buttons will also stop working. You get a yellow warning message but it's easily missed.
i am facing the problem even if the event manager is present! plz help...
Yeah I have no idea what my problem is. $$anonymous$$y buttons work fine when I enter the scene, but the buttons stop working completely when I enter the scene from another scene. Both occasions everything is the same; event system, buttons, canvas. Nothing has changed with them and yet the buttons become inactive when I enter from another scene.
Edit: I fixed my problem. Turned out the scene I was transitioning from had a DontDestroyOnLoad script attached to it. When I unchecked this the buttons work when I transition from that scene to the one with previously inactive buttons. Very strange, especially considering that script tells it to delete when it enters that scene (so it techinically does destroy itself when it loaded into the scene). Seems like the event system absolutely hates having any DontDestroyOnLoad components attached to it...
this worked for me thx :) I just added the eventSystem to DontDestroyOnLoad Object
Answer by ad172 · Dec 14, 2016 at 06:55 AM
I had the same issue, but I checked "Force Module Active" in "Standalone Input Module (Script)" in the EventSystem and it worked fine.
Answer by Fdudka · Mar 23, 2016 at 11:38 AM
try adding Time.timeScale = 1; at Start(){}
Time.timeScale = 1 in Start method worked for me too. $$anonymous$$uch thanks!
I LOVE YOU !!!!!!!
You literally saved my hours of searching !!
Answer by bdilloughery_mvla · Apr 29, 2019 at 01:57 PM
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
Cheers
Answer by SortOth · Aug 23, 2019 at 05:52 PM
For me, it was failing because I loaded level like this:
SceneManager.LoadScene("Preview", LoadSceneMode.Additive);
But now I load it with
LoadSceneMode.Single
Don't you do it like this?:
Scene$$anonymous$$anager.LoadScene("Level X")
Or like this?
public string levelToLoad;
void Start(){
Scene$$anonymous$$anager.LoadScene(levelToLoad);
}
Your answer
Follow this Question
Related Questions
HELP! Buttons stop working when made a child of a "Canvas Group" empty in 4.6.3f1? 4 Answers
Buttons scale keep changing to 0 when I import them to a non-active parent 0 Answers
How can I select a UI element with a raycast from another UI element? 2 Answers
UI Button : Previously working but now it's not working 0 Answers
Canvas Button need to be pressed higher on certain Android Phones 0 Answers