Saturday, June 11, 2022
HomeGame Developmentc# - Unity: The way to reference an object that was not...

c# – Unity: The way to reference an object that was not destroyed from a earlier scene within the inspector


In a sport I am engaged on, I’ve a button on the pause menu that permits me to mute and unmute the background music. The toggle button, within the inspector, references the audio supervisor object and calls the operate to replace the sound when the button is pressed. This labored nicely till just lately after I made my audio supervisor persist throughout all scenes to keep away from the music restarting between ranges. Consequently, when the following scene masses, the audio supervisor can’t be discovered by the toggle button (which I’d ordinarily have to tug into the toggle buttons “On Worth Modified” subject from the inspector.

Is there a approach round this, or am I going to must make my pause menu persist throughout all scenes, too? If I do that, then how ought to I deal with scenes like the primary menu or sport over menu after they haven’t got pause menu objects? Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments