public void Load_MultipleInstancesOfSameSubScene_With_NewInstance_Flag()
        {
            var postLoadCommandBuffer1 = CreateTestProcessAfterLoadDataCommandBuffer(42);
            var postLoadCommandBuffer2 = CreateTestProcessAfterLoadDataCommandBuffer(7);

            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                var sceneSystem = world.GetExistingSystem <SceneSystem>();
                var loadParams  = new SceneSystem.LoadParameters
                {
                    Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn | SceneLoadFlags.NewInstance
                };

                Assert.IsTrue(SceneGUID.IsValid);

                var scene1 = sceneSystem.LoadSceneAsync(SceneGUID, loadParams);
                world.EntityManager.AddComponentData(scene1, postLoadCommandBuffer1);

                var scene2 = sceneSystem.LoadSceneAsync(SceneGUID, loadParams);
                world.EntityManager.AddComponentData(scene2, postLoadCommandBuffer2);

                world.Update();

                var ecsTestDataQuery = world.EntityManager.CreateEntityQuery(typeof(TestProcessAfterLoadData));
                using (var ecsTestDataArray = ecsTestDataQuery.ToComponentDataArray <TestProcessAfterLoadData>(Allocator.TempJob))
                {
                    CollectionAssert.AreEquivalent(new[] { 8, 43 }, ecsTestDataArray.ToArray().Select(e => e.Value));
                }
            }
        }
Exemplo n.º 2
0
    public void SimpleHybridComponent()
    {
        TestUtilities.RegisterSystems(World, TestUtilities.SystemCategories.Streaming | TestUtilities.SystemCategories.HybridComponents);

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

        var sceneGUID = new GUID(AssetDatabase.AssetPathToGUID("Assets/StressTests/HybridLights/HybridLights/SubScene.unity"));

        World.GetExistingSystem <SceneSystem>().LoadSceneAsync(sceneGUID, loadParams);
        World.Update();


        var entity    = EmptySystem.GetSingletonEntity <Light>();
        var companion = m_Manager.GetComponentObject <Light>(entity).gameObject;

        void MoveAndCheck(float3 testpos)
        {
            m_Manager.SetComponentData(entity, new LocalToWorld {
                Value = float4x4.Translate(testpos)
            });
            World.Update();
            Assert.AreEqual(testpos, (float3)companion.transform.position);
        }

        MoveAndCheck(new float3(1, 2, 3));
        MoveAndCheck(new float3(2, 3, 4));
    }
        public void LoadSceneAsync_DeleteSceneEntityUnloadsAllSections()
        {
            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
                };

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

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

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

                manager.DestroyEntity(sceneEntity);
                world.Update();

                Assert.AreEqual(0, subSceneSectionTestDataQuery.CalculateEntityCount());
            }
        }
Exemplo n.º 4
0
        public IEnumerator LoadSubscene_With_PostLoadCommandBuffer([Values] bool loadAsync, [Values] bool addCommandBufferToSection)
        {
            var postLoadCommandBuffer = new PostLoadCommandBuffer();

            postLoadCommandBuffer.CommandBuffer = new EntityCommandBuffer(Allocator.Persistent, PlaybackPolicy.MultiPlayback);
            var postLoadEntity = postLoadCommandBuffer.CommandBuffer.CreateEntity();

            postLoadCommandBuffer.CommandBuffer.AddComponent(postLoadEntity, new TestProcessAfterLoadData {
                Value = 42
            });

            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                if (addCommandBufferToSection)
                {
                    var resolveParams = new SceneSystem.LoadParameters
                    {
                        Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.DisableAutoLoad
                    };
                    world.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(m_SceneGUID, resolveParams);
                    world.Update();
                    var section = world.EntityManager.CreateEntityQuery(typeof(SceneSectionData)).GetSingletonEntity();
                    world.EntityManager.AddComponentData(section, postLoadCommandBuffer);
                }

                var loadParams = new SceneSystem.LoadParameters
                {
                    Flags = loadAsync ? 0 : SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                };

                Assert.IsTrue(m_SceneGUID.IsValid);

                var scene = world.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(m_SceneGUID, loadParams);
                if (!addCommandBufferToSection)
                {
                    world.EntityManager.AddComponentData(scene, postLoadCommandBuffer);
                }

                if (loadAsync)
                {
                    while (!world.GetExistingSystem <SceneSystem>().IsSceneLoaded(scene))
                    {
                        world.Update();
                        yield return(null);
                    }
                }
                else
                {
                    world.Update();
                    Assert.IsTrue(world.GetExistingSystem <SceneSystem>().IsSceneLoaded(scene));
                }

                var ecsTestDataQuery = world.EntityManager.CreateEntityQuery(typeof(TestProcessAfterLoadData));
                Assert.AreEqual(1, ecsTestDataQuery.CalculateEntityCount());
                Assert.AreEqual(43, ecsTestDataQuery.GetSingleton <TestProcessAfterLoadData>().Value);
            }

            // Check that command buffer has been Disposed
            Assert.IsFalse(postLoadCommandBuffer.CommandBuffer.IsCreated);
        }
        public void Load_MultipleInstancesOfSameSubScene_By_Instantiating_ResolvedScene()
        {
            var postLoadCommandBuffer1 = CreateTestProcessAfterLoadDataCommandBuffer(42);
            var postLoadCommandBuffer2 = CreateTestProcessAfterLoadDataCommandBuffer(7);

            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                var sceneSystem   = world.GetExistingSystem <SceneSystem>();
                var resolvedScene = sceneSystem.LoadSceneAsync(SceneGUID, new SceneSystem.LoadParameters {
                    AutoLoad = false, Flags = SceneLoadFlags.BlockOnImport
                });
                world.Update();

                Assert.IsTrue(world.EntityManager.HasComponent <ResolvedSectionEntity>(resolvedScene));

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

                Assert.IsTrue(SceneGUID.IsValid);

                var scene1 = world.EntityManager.Instantiate(resolvedScene);
                world.EntityManager.AddComponentData(scene1, postLoadCommandBuffer1);
                sceneSystem.LoadSceneAsync(scene1, loadParams);


                var scene2 = world.EntityManager.Instantiate(resolvedScene);
                world.EntityManager.AddComponentData(scene2, postLoadCommandBuffer2);
                sceneSystem.LoadSceneAsync(scene2, loadParams);

                world.Update();

                var ecsTestDataQuery = world.EntityManager.CreateEntityQuery(typeof(TestProcessAfterLoadData));
                using (var ecsTestDataArray = ecsTestDataQuery.ToComponentDataArray <TestProcessAfterLoadData>(Allocator.TempJob))
                {
                    CollectionAssert.AreEquivalent(new[] { 8, 43 }, ecsTestDataArray.ToArray().Select(e => e.Value));
                }

                world.EntityManager.DestroyEntity(scene1);
                world.Update();
                using (var ecsTestDataArray = ecsTestDataQuery.ToComponentDataArray <TestProcessAfterLoadData>(Allocator.TempJob))
                {
                    CollectionAssert.AreEquivalent(new[] { 8 }, ecsTestDataArray.ToArray().Select(e => e.Value));
                }

                world.EntityManager.DestroyEntity(scene2);
                world.Update();
                using (var ecsTestDataArray = ecsTestDataQuery.ToComponentDataArray <TestProcessAfterLoadData>(Allocator.TempJob))
                {
                    Assert.AreEqual(0, ecsTestDataArray.Length);
                }
            }
        }
        public void SectionMetadata()
        {
            using (var world = TestWorldSetup.CreateEntityWorld("World", false))
            {
                var resolveParams = new SceneSystem.LoadParameters
                {
                    Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.DisableAutoLoad
                };
                var sceneSystem = world.GetOrCreateSystem <SceneSystem>();
                var sceneEntity = sceneSystem.LoadSceneAsync(SceneGUID, resolveParams);
                world.Update();
                var manager         = world.EntityManager;
                var sectionEntities = manager.GetBuffer <ResolvedSectionEntity>(sceneEntity);

                Assert.AreEqual(3, sectionEntities.Length);
                Assert.IsTrue(manager.HasComponent <TestMetadata>(sectionEntities[0].SectionEntity));
                Assert.IsFalse(manager.HasComponent <TestMetadata>(sectionEntities[1].SectionEntity));
                Assert.IsTrue(manager.HasComponent <TestMetadata>(sectionEntities[2].SectionEntity));

                Assert.IsTrue(manager.HasComponent <TestMetadataTag>(sectionEntities[0].SectionEntity));
                Assert.IsFalse(manager.HasComponent <TestMetadataTag>(sectionEntities[1].SectionEntity));
                Assert.IsTrue(manager.HasComponent <TestMetadataTag>(sectionEntities[2].SectionEntity));

                // These components should not be added, instead an error is logged that meta info components can't contain entities or blob assets
                var filteredTypes = new[]
                {
                    typeof(TestMetadataWithEntity), typeof(TestMetadataWithBlobAsset), typeof(EcsTestSharedComp), typeof(EcsIntElement), typeof(EcsState1),
#if !UNITY_DISABLE_MANAGED_COMPONENTS
                    typeof(EcsTestManagedComponent)
#endif
                };

                foreach (var type in filteredTypes)
                {
                    var componentType = ComponentType.FromTypeIndex(TypeManager.GetTypeIndex(type));
                    Assert.IsFalse(manager.HasComponent(sectionEntities[0].SectionEntity, componentType));
                }

                Assert.AreEqual(0, manager.GetComponentData <TestMetadata>(sectionEntities[0].SectionEntity).SectionIndex);
                Assert.AreEqual(13, manager.GetComponentData <TestMetadata>(sectionEntities[0].SectionEntity).Value);
                Assert.AreEqual(42, manager.GetComponentData <TestMetadata>(sectionEntities[2].SectionEntity).SectionIndex);
                Assert.AreEqual(100, manager.GetComponentData <TestMetadata>(sectionEntities[2].SectionEntity).Value);

                var hash = EntityScenesPaths.GetSubSceneArtifactHash(SceneGUID, sceneSystem.BuildConfigurationGUID, true, ImportMode.Synchronous);
                Assert.IsTrue(hash.IsValid);
                AssetDatabaseCompatibility.GetArtifactPaths(hash, out var paths);
                var logPath = EntityScenesPaths.GetLoadPathFromArtifactPaths(paths, EntityScenesPaths.PathType.EntitiesConversionLog);
                Assert.NotNull(logPath);
                var log = System.IO.File.ReadAllText(logPath);
                Assert.IsTrue(log.Contains("The component type must contains only blittable/basic data types"));
                Assert.IsFalse(log.Contains("entities in the scene 'TestSubSceneWithSectionMetadata' had no SceneSection and as a result were not serialized at all."));
            }
        }
        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))
                                        );
            }
        }
Exemplo n.º 8
0
    public void SynchronousLoad()
    {
        TestUtilities.RegisterSystems(World, TestUtilities.SystemCategories.Streaming);

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

        var sceneGUID = new GUID(AssetDatabase.AssetPathToGUID("Assets/StressTests/SubSceneTests/SubSceneHost/SubSceneA.unity"));

        World.GetExistingSystem <SceneSystem>().LoadSceneAsync(sceneGUID, loadParams);
        World.Update();

        // Expected entities:
        // 1. Scene
        // 2. Section
        // 3. Cube
        // 4. Public references
        // 5. Time singleton
        // 6. RetainBlobAssets
        Assert.AreEqual(6, m_Manager.UniversalQuery.CalculateEntityCount());
    }
Exemplo n.º 9
0
    protected override void OnUpdate()
    {
        Entities
        .ForEach((Entity e, ref SubSceneLoadRequest loadRequest) => {
            var loadParameters = new SceneSystem.LoadParameters {
                Flags = SceneLoadFlags.LoadAdditive
            };

            SceneSystem.LoadSceneAsync(loadRequest.SceneHash, loadParameters);
            EntityManager.DestroyEntity(e);
        })
        .WithStructuralChanges()
        .WithoutBurst()
        .Run();
        Entities

        .ForEach((Entity e, ref SubSceneUnloadRequest unloadRequest) => {
            SceneSystem.UnloadScene(unloadRequest.SceneHash);
            EntityManager.DestroyEntity(e);
        })
        .WithStructuralChanges()
        .WithoutBurst()
        .Run();
    }
        public void LoadMultipleSubscenes_Blocking_WithAssetBundles()
        {
            using (var worldA = TestWorldSetup.CreateEntityWorld("World A", false))
                using (var worldB = TestWorldSetup.CreateEntityWorld("World B", false))
                {
                    var loadParams = new SceneSystem.LoadParameters
                    {
                        Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
                    };

                    Assert.IsTrue(SceneGUID.IsValid);

                    var worldAScene = worldA.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(SceneGUID, loadParams);
                    var worldBScene = worldB.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(SceneGUID, loadParams);
                    Assert.IsFalse(worldA.GetExistingSystem <SceneSystem>().IsSceneLoaded(worldAScene));
                    Assert.IsFalse(worldB.GetExistingSystem <SceneSystem>().IsSceneLoaded(worldBScene));

                    worldA.Update();
                    worldB.Update();

                    Assert.IsTrue(worldA.GetExistingSystem <SceneSystem>().IsSceneLoaded(worldAScene));
                    Assert.IsTrue(worldB.GetExistingSystem <SceneSystem>().IsSceneLoaded(worldBScene));

                    var worldAEntities = worldA.EntityManager.GetAllEntities(Allocator.TempJob);
                    var worldBEntities = worldB.EntityManager.GetAllEntities(Allocator.TempJob);
                    using (worldAEntities)
                        using (worldBEntities)
                        {
                            Assert.AreEqual(worldAEntities.Length, worldBEntities.Length);
                        }

                    var worldAQuery = worldA.EntityManager.CreateEntityQuery(typeof(SharedWithMaterial));
                    var worldBQuery = worldB.EntityManager.CreateEntityQuery(typeof(SharedWithMaterial));
                    Assert.AreEqual(worldAQuery.CalculateEntityCount(), worldBQuery.CalculateEntityCount());
                    Assert.AreEqual(1, worldAQuery.CalculateEntityCount());

                    // Get Material on RenderMesh
                    var sharedEntitiesA = worldAQuery.ToEntityArray(Allocator.TempJob);
                    var sharedEntitiesB = worldBQuery.ToEntityArray(Allocator.TempJob);

                    SharedWithMaterial sharedA;
                    SharedWithMaterial sharedB;
                    using (sharedEntitiesA)
                        using (sharedEntitiesB)
                        {
                            sharedA = worldA.EntityManager.GetSharedComponentData <SharedWithMaterial>(sharedEntitiesA[0]);
                            sharedB = worldB.EntityManager.GetSharedComponentData <SharedWithMaterial>(sharedEntitiesB[0]);
                        }

                    Assert.AreSame(sharedA.material, sharedB.material);
                    Assert.IsTrue(sharedA.material != null, "sharedA.material != null");

                    var material = sharedA.material;

#if !UNITY_EDITOR
                    Assert.AreEqual(1, SceneBundleHandle.GetLoadedCount());
#else
                    Assert.AreEqual(0, SceneBundleHandle.GetLoadedCount());
#endif
                    Assert.AreEqual(0, SceneBundleHandle.GetUnloadingCount());

                    worldA.GetOrCreateSystem <SceneSystem>().UnloadScene(worldAScene);
                    worldA.Update();

                    worldB.GetOrCreateSystem <SceneSystem>().UnloadScene(worldBScene);
                    worldB.Update();

                    Assert.AreEqual(0, SceneBundleHandle.GetLoadedCount());
                    Assert.AreEqual(0, SceneBundleHandle.GetUnloadingCount());
#if !UNITY_EDITOR
                    Assert.IsTrue(material == null);
#endif
                }
        }
        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)));
            }
        }
Exemplo n.º 12
0
        public void LoadAndUnloadSubScene()
        {
            using (var worldA = new World("World A"))
                using (var worldB = new World("World B"))
                {
                    RegisterStreamingSystems(worldA);
                    RegisterStreamingSystems(worldB);

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

#if UNITY_EDITOR
                    Debug.Log(AssetDatabase.AssetPathToGUID(m_SubScenePath));
                    Unity.Entities.Hash128 sceneGuid = new GUID(AssetDatabase.AssetPathToGUID(m_SubScenePath));
#else
                    var sceneGuid = new Unity.Entities.Hash128();
#endif

                    var worldAScene = worldA.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(sceneGuid, loadParams);
                    worldA.Update();

                    var worldBScene = worldB.GetOrCreateSystem <SceneSystem>().LoadSceneAsync(sceneGuid, loadParams);
                    worldB.Update();

                    var worldAEntities = worldA.EntityManager.GetAllEntities(Allocator.TempJob);
                    var worldBEntities = worldB.EntityManager.GetAllEntities(Allocator.TempJob);
                    using (worldAEntities)
                        using (worldBEntities)
                        {
                            Assert.AreEqual(worldAEntities.Length, worldBEntities.Length);
                        }

                    var worldAQuery = worldA.EntityManager.CreateEntityQuery(typeof(SharedWithMaterial));
                    var worldBQuery = worldB.EntityManager.CreateEntityQuery(typeof(SharedWithMaterial));
                    Assert.AreEqual(worldAQuery.CalculateEntityCount(), worldBQuery.CalculateEntityCount());
                    Assert.AreEqual(1, worldAQuery.CalculateEntityCount());

                    // Get Material on RenderMesh
                    var sharedEntitiesA = worldAQuery.ToEntityArray(Allocator.TempJob);
                    var sharedEntitiesB = worldBQuery.ToEntityArray(Allocator.TempJob);

                    SharedWithMaterial sharedA;
                    SharedWithMaterial sharedB;
                    using (sharedEntitiesA)
                        using (sharedEntitiesB)
                        {
                            sharedA = worldA.EntityManager.GetSharedComponentData <SharedWithMaterial>(sharedEntitiesA[0]);
                            sharedB = worldB.EntityManager.GetSharedComponentData <SharedWithMaterial>(sharedEntitiesB[0]);
                        }

                    Assert.AreSame(sharedA.material, sharedB.material);
                    Assert.IsTrue(sharedA.material != null, "sharedA.material != null");

                    var material = sharedA.material;

#if !UNITY_EDITOR
                    Assert.AreEqual(1, SceneBundleHandle.GetLoadedCount());
#else
                    Assert.AreEqual(0, SceneBundleHandle.GetLoadedCount());
#endif
                    Assert.AreEqual(0, SceneBundleHandle.GetUnloadingCount());

                    worldA.GetOrCreateSystem <SceneSystem>().UnloadScene(worldAScene);
                    worldA.Update();

                    worldB.GetOrCreateSystem <SceneSystem>().UnloadScene(worldBScene);
                    worldB.Update();

                    Assert.AreEqual(0, SceneBundleHandle.GetLoadedCount());
                    Assert.AreEqual(0, SceneBundleHandle.GetUnloadingCount());
#if !UNITY_EDITOR
                    Assert.IsTrue(material == null);
#endif
                }
        }