示例#1
0
        internal static bool IsGameObjectSceneLoaded(SceneSystem sys, Entity entity)
        {
            if (!sys.EntityManager.HasComponent <GameObjectSceneData>(entity))
            {
                return(false);
            }

            var unitySceneReference = sys.EntityManager.GetSharedComponentData <GameObjectSceneData>(entity);

            if (!unitySceneReference.Scene.IsValid() || !unitySceneReference.Scene.isLoaded)
            {
                return(false);
            }

            if (!sys.EntityManager.HasComponent <GameObjectSceneSubScene>(entity))
            {
                return(false);
            }

            var subSceneEntities = sys.EntityManager.GetBuffer <GameObjectSceneSubScene>(entity);

            foreach (var subScene in subSceneEntities)
            {
                // If a SubScene has AutoLoad DISABLED then it will return false from IsSceneLoaded. So in this case, it's not enough
                // to just check if a SubScene of this GameObject Scene is loaded, we also need to check if the NOT loaded SubScene
                // is actually AutoLoad DISABLED, in which case that is not a reason to indicate this GameObject Scene is not loaded.
                if (sys.EntityManager.Exists(subScene.SceneEntity) && !sys.IsSceneLoaded(subScene.SceneEntity))
                {
                    if (sys.EntityManager.HasComponent <RequestSceneLoaded>(subScene.SceneEntity))
                    {
                        var request = sys.EntityManager.GetComponentData <RequestSceneLoaded>(subScene.SceneEntity);
                        if (request.LoadFlags.HasFlag(SceneLoadFlags.DisableAutoLoad))
                        {
                            continue;
                        }
                    }
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
 bool IsSceneLoaded(Entity sceneEntity)
 {
     return(m_SceneSystem.IsSceneLoaded(sceneEntity));
 }