Question by
k_motlagh · Jan 19, 2021 at 08:20 PM ·
gameobjectbuttonsoundaudiosource
dontDestroyOnLoad() - When is the gameObject destroyed?
Hi,
i have a gameObject with two components. One 'Audio Source' and a 'Script' which is calling 'DontDestroyOnLoad' for this gameObject.
I have also a button on scene1 which is loading scene2 and playing a 'click' sound from the gameObject above when the user clicks on the button. Everything works fine. But Im wondering what happens with the gameObject when the user switches between the scenes multiple times? When is the gameObject destroyed? Never?
Is this a proper way to play a 'click' sound when the user clicks on the button? I want to add sound to all buttons in the whole game...
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613023620im_/https://answers.unity.com/themes/thub/images/avi.jpg)