Example #1
0
        public void ConversionIsBuildingForEditor()
        {
            var gameObject = CreateGameObject("", typeof(TestComponentAuthoringIsBuildingForEditor));

            ConvertGameObjectHierarchy(gameObject, MakeDefaultSettings());
            EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial(new IntTestData(1)));
        }
        public void LoadSceneAsync_LoadsAllSections()
        {
            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                var manager     = world.EntityManager;
                var sceneSystem = world.GetOrCreateSystem <SceneSystem>();

                var resolveParams = new SceneSystem.LoadParameters
                {
                    Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                };

                sceneSystem.LoadSceneAsync(SceneGUID, resolveParams);
                world.Update();

                EntitiesAssert.Contains(manager,
                                        EntityMatch.Partial(new SubSceneSectionTestData(42)),
                                        EntityMatch.Partial(new SubSceneSectionTestData(43)),
                                        EntityMatch.Partial(new SubSceneSectionTestData(44))
                                        );
            }
        }
        public void CanLoadSectionsIndividually()
        {
            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                var manager     = world.EntityManager;
                var sceneSystem = world.GetOrCreateSystem <SceneSystem>();

                var resolveParams = new SceneSystem.LoadParameters
                {
                    Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn | SceneLoadFlags.DisableAutoLoad
                };

                var subSceneSectionTestDataQuery = manager.CreateEntityQuery(typeof(SubSceneSectionTestData));

                var sceneEntity = sceneSystem.LoadSceneAsync(SceneGUID, resolveParams);
                world.Update();

                Assert.AreEqual(0, subSceneSectionTestDataQuery.CalculateEntityCount());

                var section0Entity  = FindSectionEntity(manager, sceneEntity, 0);
                var section10Entity = FindSectionEntity(manager, sceneEntity, 10);
                var section20Entity = FindSectionEntity(manager, sceneEntity, 20);
                Assert.AreNotEqual(Entity.Null, section0Entity);
                Assert.AreNotEqual(Entity.Null, section10Entity);
                Assert.AreNotEqual(Entity.Null, section20Entity);

                Assert.IsFalse(sceneSystem.IsSectionLoaded(section0Entity));
                Assert.IsFalse(sceneSystem.IsSectionLoaded(section10Entity));
                Assert.IsFalse(sceneSystem.IsSectionLoaded(section20Entity));

                manager.AddComponentData(section0Entity,
                                         new RequestSceneLoaded {
                    LoadFlags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                });

                world.Update();

                Assert.IsTrue(sceneSystem.IsSectionLoaded(section0Entity));
                Assert.IsFalse(sceneSystem.IsSectionLoaded(section10Entity));
                Assert.IsFalse(sceneSystem.IsSectionLoaded(section20Entity));

                Assert.AreEqual(1, subSceneSectionTestDataQuery.CalculateEntityCount());
                Assert.AreEqual(42, subSceneSectionTestDataQuery.GetSingleton <SubSceneSectionTestData>().Value);

                manager.AddComponentData(section20Entity,
                                         new RequestSceneLoaded {
                    LoadFlags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                });
                world.Update();

                Assert.IsTrue(sceneSystem.IsSectionLoaded(section0Entity));
                Assert.IsFalse(sceneSystem.IsSectionLoaded(section10Entity));
                Assert.IsTrue(sceneSystem.IsSectionLoaded(section20Entity));

                Assert.AreEqual(2, subSceneSectionTestDataQuery.CalculateEntityCount());
                EntitiesAssert.Contains(manager,
                                        EntityMatch.Partial(new SubSceneSectionTestData(42)),
                                        EntityMatch.Partial(new SubSceneSectionTestData(44)));


                manager.AddComponentData(section10Entity,
                                         new RequestSceneLoaded {
                    LoadFlags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                });
                world.Update();

                Assert.IsTrue(sceneSystem.IsSectionLoaded(section0Entity));
                Assert.IsTrue(sceneSystem.IsSectionLoaded(section10Entity));
                Assert.IsTrue(sceneSystem.IsSectionLoaded(section20Entity));

                Assert.AreEqual(3, subSceneSectionTestDataQuery.CalculateEntityCount());
                EntitiesAssert.Contains(manager,
                                        EntityMatch.Partial(new SubSceneSectionTestData(42)),
                                        EntityMatch.Partial(new SubSceneSectionTestData(43)),
                                        EntityMatch.Partial(new SubSceneSectionTestData(44)));
            }
        }