i searched for related topics for my problem, they seems useful but i cant implement in my project, i cant find the logic in their answers. so simple question. i have this button which is a “Speaker On” Icon. if i clicked this, the icon will change to Speaker Off and all the sound in my scenes will be turn off. btw, my background music is in my first scene(main scene) and it is attached to empty game object. here is the code i got so far.
public var SoundClip : AudioClip;
private var SoundSource : AudioSource;
function Awake()
{
DontDestroyOnLoad(gameObject);
SoundSource = gameObject.AddComponent(AudioSource);
SoundSource.loop = true;
SoundSource.volume = 0.8;
}
function Start()
{
SoundSource.clip = SoundClip;
SoundSource.Play();
}
can someone help me please? it would be very much appreciated.