So I am fairly new to unity and #C I have this don’t destroy script on a backgroundmusic object but I don’t want it to play in the menu after I return there from the game. Any idea about how to do this? Can I use the “Music” tag to check if there already is something there and then make it destroy itself?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dontdestroy : MonoBehaviour {
// Use this for initialization
private void Awake()
{
GameObject[] objs = GameObject.FindGameObjectsWithTag("music");
if (objs.Length > 1)
Destroy(this.gameObject);
DontDestroyOnLoad(this.gameObject);
}
}