Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

How to have different background music through different scenes?

$
0
0
I have a lot of 2D scenes, and I want Scene 1 - 3 to have the same background music playing seamlessly if the user changes between them. However, I also want to change this background music so that when the user enters Scene 4 - 6, it changes to another track but also plays seamlessly between scenes 4 - 6. I'm currently using this code to play the sound between scenes, but because i'm fairly new to unity & c#, I can't find a solution to stop this audio and get it to start playing another when Scene 4 starts. using UnityEngine; public class DoNotDestroy : MonoBehaviour { private void Awake() { GameObject[] musicObj = GameObject.FindGameObjectsWithTag("GameMusic"); if( musicObj.Length > 1) { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); } }

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>