コード例 #1
0
        public void Dispose()
        {
            if (!IsCreated)
            {
                throw new ArgumentException("The World has already been Disposed.");
            }
            // Debug.LogError("Dispose World "+ Name + " - " + GetHashCode());

            m_EntityManager.PreDisposeCheck();
            s_AllWorlds.Remove(this);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            m_AllowGetSystem = false;
#endif
            DestroyAllSystemsAndLogException();

            // Destroy EntityManager last
            m_EntityManager.DestroyInstance();
            m_EntityManager = null;

#if !UNITY_DOTSPLAYER
            m_SystemLookup.Clear();
            m_SystemLookup = null;
#endif

            if (DefaultGameObjectInjectionWorld == this)
            {
                DefaultGameObjectInjectionWorld = null;
            }
        }
コード例 #2
0
        public void Dispose()
        {
            if (!IsCreated)
            {
                throw new ArgumentException("The World has already been Disposed.");
            }
            // Debug.LogError("Dispose World "+ Name + " - " + GetHashCode());

            m_EntityManager.PreDisposeCheck();

            if (allWorlds.Contains(this))
            {
                allWorlds.Remove(this);
            }

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            m_AllowGetSystem = false;
#endif
            // Destruction should happen in reverse order to construction
            for (int i = m_Systems.Count - 1; i >= 0; --i)
            {
                try
                {
                    m_Systems[i].DestroyInstance();
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            // Destroy EntityManager last
            m_EntityManager.DestroyInstance();
            m_EntityManager = null;

            m_Systems.Clear();
            m_Systems = null;

#if !UNITY_DOTSPLAYER
            m_SystemLookup.Clear();
            m_SystemLookup = null;
#endif

            if (DefaultGameObjectInjectionWorld == this)
            {
                DefaultGameObjectInjectionWorld = null;
            }
        }