Can Not Play Disabled Audio Source
I have the audio source set to not destroy, and it's continuing to play the original song it was set to, but I cannot play the new song I'm trying to set it to. I have checked other questions asking the same answer and attempted their solutions, but cannot get it to work.
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
private void Start()
{
Load();
audioSource.Play();
cheatCount = 0;
if (volumeOff)
{
AudioListener.volume = 0.0f;
} else
{
AudioListener.volume = 1.0f;
}
}
public void LoadLevel(string name)
{
Save();
Scene current = SceneManager.GetActiveScene();
string currentName = current.name;
lastScene = currentName;
SceneManager.LoadScene(name);
if (name == "Level2")
{
audioSource.clip = Resources.Load<AudioClip>("Audio\\Escape! Soundtrack10");
audioSource.enabled = true;
audioSource.Play();
}
}
Answer by meat5000 · Mar 11, 2018 at 01:32 AM
Did you unload?
https://docs.unity3d.com/ScriptReference/Resources.UnloadAsset.html
https://docs.unity3d.com/ScriptReference/AudioClip.UnloadAudioData.html
You maybe need to link it with GetComponent
Your answer
Follow this Question
Related Questions
How to stop and re-start audio? 1 Answer
Creating a Custom Music folder - Works inside the editor - Issues with build. 0 Answers
Second AudioClip won't play 0 Answers
Second AudioClip won't play 0 Answers
Take 2: Audio silent in Play Mode. 0 Answers