유니티 싱글톤


public class Singleton: MonoBehaviour
{
    public static Singleton Instance;             
    //Awake is always called before any Start functions
    void Awake()
    {
        if (Instance)
        {
             DestroyImmediate(gameObject);
        }
        else
        {
             Instance = this;
             DontDestroyOnLoad(gameObject);

        }
    }
}

댓글

이 블로그의 인기 게시물

유니티 오브젝트 서서히 사라지게

WebView에서 YOUTUBE 동영상 플레이 방법