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?
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.
Don't you do it like this?: SceneManager.LoadScene("Level X") Or like this? public string levelToLoad; void Start(){ SceneManager.LoadScene(levelToLoad); }
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.
– bodecIt'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.
– grimmyi am facing the problem even if the event manager is present! plz help...
– roshan67890this worked for me thx :) I just added the eventSystem to DontDestroyOnLoad Object
– AltSimThank you so much!
– Nemanja2001