Inheritance: ScriptableObject
示例#1
0
        void OnEnable()
        {
    #if UNITY_EDITOR
            if (UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(gameObject) != null)
            {
                return;
            }

            m_SubSceneHeader = null;
            if (SceneAsset == null)
            {
                return;
            }

            foreach (var subscene in m_AllSubScenes)
            {
                if (subscene.SceneAsset == SceneAsset)
                {
                    Debug.LogWarning($"A sub-scene can not include the same scene ('{EditableScenePath}') multiple times.", this);
                    return;
                }
            }

            m_AllSubScenes.Add(this);
    #endif

            UpdateSceneEntities(true);
        }
示例#2
0
        public void UpdateSceneEntities()
        {
#if UNITY_EDITOR
            var sceneHeaderPath = EntityScenesPaths.GetLoadPath(SceneGUID, EntityScenesPaths.PathType.EntitiesHeader, -1);
            m_SubSceneHeader = AssetDatabase.LoadAssetAtPath <SubSceneHeader>(sceneHeaderPath);
#endif

            if (_SceneEntityManager != null && _SceneEntityManager.IsCreated)
            {
                foreach (var sceneEntity in _SceneEntities)
                {
                    _SceneEntityManager.DestroyEntity(sceneEntity);
                }
            }
            _SceneEntities.Clear();
            _SceneEntityManager = null;

            DefaultWorldInitialization.DefaultLazyEditModeInitialize();
            if (World.Active != null && m_SubSceneHeader != null)
            {
                _SceneEntityManager = World.Active.EntityManager;

                for (int i = 0; i < m_SubSceneHeader.Sections.Length; ++i)
                {
                    var sceneEntity = _SceneEntityManager.CreateEntity();
                    #if UNITY_EDITOR
                    _SceneEntityManager.SetName(sceneEntity, i == 0 ? $"Scene: {SceneName}" : $"Scene: {SceneName} ({i})");
                    #endif

                    _SceneEntities.Add(sceneEntity);
                    _SceneEntityManager.AddComponentObject(sceneEntity, this);

                    if (AutoLoadScene)
                    {
                        _SceneEntityManager.AddComponentData(sceneEntity, new RequestSceneLoaded());
                    }

                    _SceneEntityManager.AddComponentData(sceneEntity, m_SubSceneHeader.Sections[i]);
                    _SceneEntityManager.AddComponentData(sceneEntity, new SceneBoundingVolume {
                        Value = m_SubSceneHeader.Sections[i].BoundingVolume
                    });
                }
            }
        }
示例#3
0
        void OnEnable()
        {
    #if UNITY_EDITOR
            if (UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(gameObject) != null)
            {
                return;
            }

            m_SubSceneHeader = null;
            if (SceneAsset == null)
            {
                return;
            }

            foreach (var subscene in m_AllSubScenes)
            {
                if (subscene.SceneAsset == SceneAsset)
                {
                    Debug.LogWarning($"A sub-scene can not include the same scene ('{EditableScenePath}') multiple times.", this);
                    return;
                }
            }

            m_AllSubScenes.Add(this);

            var sceneHeaderPath = EntityScenesPaths.GetLoadPath(SceneGUID, EntityScenesPaths.PathType.EntitiesHeader, -1);
            m_SubSceneHeader = AssetDatabase.LoadAssetAtPath <SubSceneHeader>(sceneHeaderPath);

            if (m_SubSceneHeader == null)
            {
                Debug.LogWarning($"Sub-scene '{EditableScenePath}' has no valid header at '{sceneHeaderPath}'. Please rebuild the Entity Cache.", this);
                return;
            }
    #endif

            UpdateSceneEntities();
        }
示例#4
0
        public void UpdateSceneEntities(bool warnIfMissing = false)
        {
#if UNITY_EDITOR
            var sceneHeaderPath = EntityScenesPaths.GetLoadPath(SceneGUID, EntityScenesPaths.PathType.EntitiesHeader, -1);
            m_SubSceneHeader = AssetDatabase.LoadAssetAtPath <SubSceneHeader>(sceneHeaderPath);
#endif
            if (warnIfMissing && m_SubSceneHeader == null)
            {
#if UNITY_EDITOR
                Debug.LogWarning($"Sub-scene '{EditableScenePath}' has no valid header at '{sceneHeaderPath}'. Please rebuild the Entity Cache.", this);
#else
                Debug.LogWarning($"Sub-scene '{name}' has no valid header. Please rebuild the Entity Cache.", this);
#endif
            }


            if (_SceneEntityManager != null && _SceneEntityManager.IsCreated)
            {
                foreach (var sceneEntity in _SceneEntities)
                {
                    _SceneEntityManager.DestroyEntity(sceneEntity);
                }
            }
            _SceneEntities.Clear();
            _SceneEntityManager = null;

            DefaultWorldInitialization.DefaultLazyEditModeInitialize();
            if (World.Active != null)
            {
                _SceneEntityManager = World.Active.EntityManager;

                if (m_SubSceneHeader != null)
                {
                    for (int i = 0; i < m_SubSceneHeader.Sections.Length; ++i)
                    {
                        var sceneEntity = _SceneEntityManager.CreateEntity();
                        #if UNITY_EDITOR
                        _SceneEntityManager.SetName(sceneEntity, i == 0 ? $"Scene: {SceneName}" : $"Scene: {SceneName} ({i})");
                        #endif

                        _SceneEntities.Add(sceneEntity);
                        _SceneEntityManager.AddComponentObject(sceneEntity, this);

                        if (AutoLoadScene)
                        {
                            _SceneEntityManager.AddComponentData(sceneEntity, new RequestSceneLoaded());
                        }

                        _SceneEntityManager.AddComponentData(sceneEntity, m_SubSceneHeader.Sections[i]);
                        _SceneEntityManager.AddComponentData(sceneEntity, new SceneBoundingVolume {
                            Value = m_SubSceneHeader.Sections[i].BoundingVolume
                        });
                    }
                }
                else
                {
                    var sceneEntity = _SceneEntityManager.CreateEntity();
                    #if UNITY_EDITOR
                    _SceneEntityManager.SetName(sceneEntity, "Scene: {SceneName}");
                    #endif

                    _SceneEntities.Add(sceneEntity);
                    _SceneEntityManager.AddComponentObject(sceneEntity, this);
                }
            }
        }