コード例 #1
0
        public void Convert(Scene scene, Hash128 sceneHash, GameObjectConversionUtility.ConversionFlags flags)
        {
            using (m_Convert.Auto())
            {
                // Try incremental conversion
                if (!_RequestCleanConversion)
                {
                    // Debug.Log("Incremental convert");
                    try
                    {
                        GameObjectConversionUtility.ConvertIncremental(GameObjectWorld, _ChangedGameObjects, flags);
                        _ChangedGameObjects.Clear();
                    }
                    catch (Exception e)
                    {
                        _RequestCleanConversion = true;
                        Debug.LogWarning("Incremental conversion failed. Performing full conversion instead\n" + e.ToString());
                    }
                }

                // If anything failed, fall back to clean conversion
                if (_RequestCleanConversion)
                {
                    // Debug.Log("Clean convert");
                    ConvertedWorld.EntityManager.DestroyEntity(ConvertedWorld.EntityManager.UniversalQuery);
                    GameObjectWorld = GameObjectConversionUtility.ConvertIncrementalInitialize(scene, new GameObjectConversionSettings(ConvertedWorld, sceneHash, flags));
                }

                _ChangedGameObjects.Clear();
                _RequestCleanConversion = false;
            }
        }
コード例 #2
0
        public void IncrementalConversionLinkedGroup()
        {
            var conversionFlags = GameObjectConversionUtility.ConversionFlags.GameViewLiveLink | GameObjectConversionUtility.ConversionFlags.AssignName;
            // Parent (LinkedEntityGroup) (2 additional entities)
            // - Child (2 additional entities)
            // All reference parent game object

            var parent = CreateGameObject().AddComponent <EntityRefTestDataAuthoring>();
            var child  = CreateGameObject().AddComponent <EntityRefTestDataAuthoring>();

            child.transform.parent = parent.transform;

            child.name = "child";
            child.AdditionalEntityCount    = 2;
            child.DeclareLinkedEntityGroup = false;
            child.Value = parent.gameObject;

            parent.name = "parent";
            parent.AdditionalEntityCount    = 2;
            parent.DeclareLinkedEntityGroup = true;
            parent.Value = parent.gameObject;

            using (var conversionWorld = GameObjectConversionUtility.ConvertIncrementalInitialize(SceneManager.GetActiveScene(), new GameObjectConversionSettings(World, conversionFlags)))
            {
                Entities.ForEach((ref EntityRefTestData data) =>
                                 StringAssert.StartsWith("parent", m_Manager.GetName(data.Value)));

                var entity = EmptySystem.GetSingletonEntity <LinkedEntityGroup>();

                // Parent (LinkedEntityGroup) (2 additional entities)
                // - Child (1 additional entities)
                // All reference child game object
                child.Value = child.gameObject;
                child.AdditionalEntityCount = 1;
                parent.Value = child.gameObject;
                GameObjectConversionUtility.ConvertIncremental(conversionWorld, new[] { child.gameObject }, conversionFlags);

                EntitiesAssert.ContainsOnly(m_Manager,
                                            EntityMatch.Exact <EntityRefTestData>(entity, k_CommonComponents,
                                                                                  EntityMatch.Component((LinkedEntityGroup[] group) => group.Length == 5)),
                                            EntityMatch.Exact <EntityRefTestData>(k_ChildComponents),
                                            EntityMatch.Exact <EntityRefTestData>(),
                                            EntityMatch.Exact <EntityRefTestData>(),
                                            EntityMatch.Exact <EntityRefTestData>());

                // We expect there to still only be one linked entity group and it should be the same entity as before
                // since it is attached to the primary entity which is not getting destroyed.
                Assert.AreEqual(entity, EmptySystem.GetSingletonEntity <LinkedEntityGroup>());

                Entities.ForEach((ref EntityRefTestData data) =>
                                 StringAssert.StartsWith("child", m_Manager.GetName(data.Value)));

                foreach (var e in m_Manager.GetBuffer <LinkedEntityGroup>(entity).AsNativeArray())
                {
                    Assert.IsTrue(m_Manager.Exists(e.Value));
                }
            }
        }
コード例 #3
0
        void Convert(Scene scene, Hash128 sceneGUID, GameObjectConversionUtility.ConversionFlags flags, BuildConfiguration config)
        {
            using (m_ConvertMarker.Auto())
            {
                // Try incremental conversion
                if (!_RequestCleanConversion)
                {
                    // Debug.Log("Incremental convert");
                    try
                    {
                        GameObjectConversionUtility.ConvertIncremental(_GameObjectWorld, _ChangedGameObjects, flags);
                        _ChangedGameObjects.Clear();
                    }
                    #pragma warning disable 168
                    catch (Exception e)
                    {
                        _RequestCleanConversion = true;

                        // Debug.Log("Incremental conversion failed. Performing full conversion instead\n" + e.ToString());
                    }
                    #pragma warning restore 168
                }

                // If anything failed, fall back to clean conversion
                if (_RequestCleanConversion)
                {
                    // Debug.Log("Clean convert");
                    _ConvertedWorld.EntityManager.DestroyEntity(_ConvertedWorld.EntityManager.UniversalQuery);
                    var conversionSettings = new GameObjectConversionSettings(_ConvertedWorld, flags);
                    conversionSettings.BuildConfiguration  = config;
                    conversionSettings.SceneGUID           = sceneGUID;
                    conversionSettings.DebugConversionName = _SceneName;
                    conversionSettings.BlobAssetStore      = m_BlobAssetStore;
                    conversionSettings.FilterFlags         = WorldSystemFilterFlags.HybridGameObjectConversion;

                    if (_GameObjectWorld != null && _GameObjectWorld.IsCreated)
                    {
                        _GameObjectWorld.Dispose();
                        _GameObjectWorld = null;
                    }
                    _GameObjectWorld = GameObjectConversionUtility.ConvertIncrementalInitialize(scene, conversionSettings);
                    m_AssetDependencies.Clear();
                    AddAssetDependencies(_GameObjectWorld.GetExistingSystem <GameObjectConversionMappingSystem>().Dependencies, ref m_AssetDependencies);
                }

                _ChangedGameObjects.Clear();
                _RequestCleanConversion = false;
            }
        }
コード例 #4
0
        public void Convert(Scene scene, Hash128 sceneGUID, GameObjectConversionUtility.ConversionFlags flags, BuildSettings buildSettings)
        {
            using (m_ConvertMarker.Auto())
            {
                // Try incremental conversion
                if (!_RequestCleanConversion)
                {
                    // Debug.Log("Incremental convert");
                    try
                    {
                        GameObjectConversionUtility.ConvertIncremental(_GameObjectWorld, _ChangedGameObjects, flags);
                        _ChangedGameObjects.Clear();
                    }
                    catch (Exception e)
                    {
                        _RequestCleanConversion = true;
                        Debug.LogWarning("Incremental conversion failed. Performing full conversion instead\n" + e.ToString());
                    }
                }

                // If anything failed, fall back to clean conversion
                if (_RequestCleanConversion)
                {
                    // Debug.Log("Clean convert");
                    _ConvertedWorld.EntityManager.DestroyEntity(_ConvertedWorld.EntityManager.UniversalQuery);
                    var conversionSettings = new GameObjectConversionSettings(_ConvertedWorld, flags);
                    conversionSettings.BuildSettings       = buildSettings;
                    conversionSettings.SceneGUID           = sceneGUID;
                    conversionSettings.DebugConversionName = _SceneName;
                    conversionSettings.blobAssetStore      = m_BlobAssetStore;

                    if (_GameObjectWorld != null && _GameObjectWorld.IsCreated)
                    {
                        _GameObjectWorld.Dispose();
                        _GameObjectWorld = null;
                    }
                    _GameObjectWorld = GameObjectConversionUtility.ConvertIncrementalInitialize(scene, conversionSettings);
                }

                _ChangedGameObjects.Clear();
                _RequestCleanConversion = false;
            }
        }