Exemplo n.º 1
0
 public void Dispose()
 {
     if (!m_Disposed)
     {
         m_Disposed = true;
         m_Component.referenceCount--;
         if (m_Component.referenceCount == 0)
         {
             Object.DestroyImmediate(m_GameObject);
         }
         m_GameObject = null;
         m_Component  = null;
     }
 }
Exemplo n.º 2
0
        public CoroutineExecutor()
        {
            const string hiddenObjectNames = "UnityEngine_PlayerIdentity_CoroutineExecutorHiddenGameObject";
            var          existingCoroutineExecutorGameObject = GameObject.Find(hiddenObjectNames);

            if (existingCoroutineExecutorGameObject != null)
            {
                m_GameObject = existingCoroutineExecutorGameObject;
                m_Component  = m_GameObject.GetComponent <CoroutineExecutorMonoBehaviour>();
                m_Component.referenceCount++;
                return;
            }
            m_GameObject = new GameObject(hiddenObjectNames)
            {
                hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy
            };
            m_Component = m_GameObject.AddComponent <CoroutineExecutorMonoBehaviour>();
            m_Component.referenceCount++;
            GameObject.DontDestroyOnLoad(m_GameObject);
        }