- Home /
UI Button OnClick event missing after changing back from another scene
I have 2 scenes which is a "Level Menu" scene, and the "Level" scene. In the "Level Menu" scene, I have a button in the "Level Menu" which will change the current scene to "Level". In the OnClick part of that button, I set it to play an audio from an audio source with a DontDestroyOnLoad script attached to it.
The first time the audio would work fine, but after going to the "Level" scene, then going back to the "Level Menu" scene, the button wouldn't play the audio anymore when I click it.
What I wanted to do is to make the button play a sound, but make it so that the audio doesn't disappear while changing scenes.
I've looked around and I think it's because the instance is static (?), but I don't really know what I have to do.
Can anyone help me about this? Thanks!
did you solve this? i have the same problem . Please.
Answer by halfdevil333 · Aug 10, 2016 at 07:54 PM
i am a noob aswell but have you put it under void start?
Answer by HanSoloYolo · Aug 18, 2017 at 02:52 AM
I am having the same issue. I have an empty game object called LevelManager and it has a DontDestroyOnLoad() attached. It is a static object throughout the scene changes, but during runtime it is missing from the OnClick(). It is present on the first Scene, but when I load a new scene it goes missing and the button no longer works.
HELP would be appreciated.