示例#1
0
 void OnDestroy()
 {
     m_referenceCount--;
     if (m_referenceCount == 0)
     {
         m_instance = null;
     }
 }
示例#2
0
    void Awake()
    {
        m_referenceCount++;
        if (m_referenceCount > 1)
        {
            DestroyImmediate(this.gameObject);
            return;
        }

        m_instance = this;
        // Use this line if you need the object to persist across scenes
        //DontDestroyOnLoad(this.gameObject);
    }