Beispiel #1
0
    // 유틸 : 객체 초기화
    static void Initialize(T pInstance)
    {
        if (null == pInstance)
        {
            return;
        }

        // 싱글턴 생성시 Awake에서 호출되고, Instance에서 호출되므로 같으면 무시
        if ((null != m_pInstance) && (m_pInstance == pInstance))
        {
            return;
        }

        // 인스턴스 중복체크
        T pDuplication = SHGameObject.GetDuplication(pInstance);

        if (null != pDuplication)
        {
            m_pInstance = pDuplication;
            SHGameObject.DestoryObject(pInstance.gameObject);
            return;
        }

        m_pInstance = pInstance;
        m_pInstance.SetParent("SHSingletons(Destroy)");
        m_pInstance.OnInitialize();
    }
    static void Initialize(T pInstance)
    {
        if (null == pInstance)
        {
            return;
        }

        // 초기화 무시처리 : 싱글턴 생성시 Awake에서 호출되고, Instance Property에 접근하면서 호출될 수 있므로 인스턴스가 같으면 무시
        if (m_pInstance == pInstance)
        {
            return;
        }

        // 인스턴스 중복체크 : 이미 생성된 게임오브젝트가 존재할 수 있으므로 중복체크 후 인스턴스 업데이트 처리
        T pDuplication = SHGameObject.GetDuplication(pInstance);

        if (null != pDuplication)
        {
            UnityEngine.Object.DestroyImmediate(pInstance.gameObject);
            m_pInstance = pDuplication;
            return;
        }

        m_pInstance = pInstance;
        m_pInstance.SetParent("SHSingletons(Destroy)");
        m_pInstance.OnInitialize();
    }