I am giving the user a UI button to mute and unmute the ingame sounds but the problem is when I mute the sounds and then when the game ends and the game scene reloads the sounds comes back up which is really annoying.
After some searching I came to know that I need to use
DontDestroyOnLoad(transform.gameobject); but it makes the copy of the whole thing and now I have two copies of the same music.
Also I don't know if this is the only way or not but just to mute/unmute an audio source it feels kind of overkill to me since I have a many components attached to my gameobject and then just to mute/unmute it copies the whole thing.
Can someone tell me how to fix that duplicating problem and also is there any simpler way to achieve this?