상세 컨텐츠

본문 제목

유니티 Singleton 싱글톤 노트

Unity/C# note

by 오발탄LAB 2020. 12. 15. 22:26

본문

반응형
    private static GameManager instance = null;

    private void Awake()
    {
        if (null == instance) {
            instance = this;
            DontDestroyOnLoad(this.gameObject);
        }
        else 
        {
            Destroy(this.gameObject);
        }
    }
    public static GameManager Instance 
    {
        get 
        {
            if (null == instance)
            {
                return null;
            }
            return instance;
        }
    }
반응형

'Unity > C# note' 카테고리의 다른 글

관련글 더보기

댓글 영역