I am using Unity 2019.2.8f1 personal
I have a Main Menu Scene , Game Scene
moving between scenes simply by calling
public void StartButton()
{
SceneManager.LoadScene("GameMode");
}
public void MainMenu()
{
SceneManager.LoadScene("Main Menu");
}
and I have created a Singleton for Audio by simply send a clip to be played
and here is the code
using UnityEngine;
public sealed class SoundManager
{
private static SoundManager instance;
private static AudioSource audio;
public static SoundManager singleton
{
get
{
if (instance == null)
{
instance = new SoundManager();
GameObject soundManager;
soundManager = new GameObject("SoundManager");
soundManager.AddComponent<AudioSource>();
audio = soundManager.GetComponent<AudioSource>();
audio.playOnAwake = false;
Transform.DontDestroyOnLoad(soundManager);
}
return instance;
}
}
public void Play(AudioClip clip , float volume)
{
audio.clip = clip;
audio.volume = volume;
audio.Play();
}
public void Play(AudioClip clip)
{
audio.clip = clip;
audio.Play();
}
public void Stop()
{
audio.Stop();
}
}
at start nothing wrong but once I move to game scene and then back to main menu I hear no sound in main menu until I go back go game scene and the sounds start playing when the game scene starts …
any help ?