상세 컨텐츠

본문 제목

How to keep your music playing without interruption in Unity // 유니티에서 배경음악 끊임없이 나오는법 (So Easy Used Singleton)

개발생활/Unity Engine

by 한국인맛집 2019. 10. 17. 17:32

본문

반응형

 

 

 

 

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 !

 

 

반응형

관련글 더보기