How to keep your music playing without interruption in Unity // 유니티에서 배경음악 끊임없이 나오는법 (So Easy Used Singleton)
I made name for "BgmController"
This is code [My Bgm Controller ]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class [Your Class Name] : MonoBehaviour{
private static [Your Class Name] instance = null;
// Static Indefendent Variable
private void Awake() {
if( instance != null){
Destroy(this.gameObject);
// If Instance is exist
// Destroy Object
return;
}
instance = this.GetComponent<[Your Class Name]>();
DontDestroyOnLoad(this);
// This Methods don't destroy Keep Scene
Application.targetFrameRate = 60;
}
}
Done !