Example #1
0
        public void Test2()
        {
#if !UNITY_DOTSPLAYER
            World w = new World("TestWorld");
#else
            World w = DefaultTinyWorldInitialization.Initialize("TestWorld");
#endif
            World.DefaultGameObjectInjectionWorld = w;
            EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;

            List <Entity> remember = new List <Entity>();
            for (int i = 0; i < 5; i++)
            {
                remember.Add(em.CreateEntity());
            }

            w.Dispose();
            w = null;

#if !UNITY_DOTSPLAYER
            w = new World("TestWorld2");
#else
            w = DefaultTinyWorldInitialization.Initialize("TestWorld");
#endif
            World.DefaultGameObjectInjectionWorld = w;
            em = World.DefaultGameObjectInjectionWorld.EntityManager;
            var allEnt = em.GetAllEntities(Allocator.Temp);
            Assert.AreEqual(0, allEnt.Length);
            allEnt.Dispose();

            foreach (Entity e in remember)
            {
                bool exists = em.Exists(e);
                Assert.IsFalse(exists);
            }

            foreach (Entity e in remember)
            {
                if (em.Exists(e))
                {
                    em.DestroyEntity(e);
                }
            }

            w.Dispose();
        }
Example #2
0
        public virtual void Setup()
        {
            m_PreviousWorld = World.Active;
#if !UNITY_DOTSPLAYER
            World = World.Active = new World("Test World");
#else
            World = DefaultTinyWorldInitialization.Initialize("Test World");
#endif

            m_Manager      = World.EntityManager;
            m_ManagerDebug = new EntityManager.EntityManagerDebug(m_Manager);

#if !UNITY_DOTSPLAYER
#if !UNITY_2019_2_OR_NEWER
            // Not raising exceptions can easily bring unity down with massive logging when tests fail.
            // From Unity 2019.2 on this field is always implicitly true and therefore removed.

            UnityEngine.Assertions.Assert.raiseExceptions = true;
#endif  // #if !UNITY_2019_2_OR_NEWER
#endif  // #if !UNITY_DOTSPLAYER
        }