Exemple #1
0
        AsyncLoadSceneOperation CreateAsyncLoadSceneOperation(EntityManager dstManager, Entity entity, bool blockUntilFullyLoaded)
        {
            var sceneData   = EntityManager.GetComponentData <SceneSectionData>(entity);
            var sectionData = EntityManager.GetComponentData <ResolvedSectionPath>(entity);

            var entitiesBinaryPath = sectionData.ScenePath.ToString();
            var resourcesPath      = sectionData.HybridPath.ToString();
            NativeArray <Entities.Hash128> dependencies = default;

            if (EntityManager.HasComponent <BundleElementData>(entity))
            {
                var depBuffer = EntityManager.GetBuffer <BundleElementData>(entity);
                dependencies = new NativeArray <Entities.Hash128>(depBuffer.AsNativeArray().Reinterpret <Entities.Hash128>(), Allocator.Persistent);
            }

#if !UNITY_DISABLE_MANAGED_COMPONENTS
            PostLoadCommandBuffer postLoadCommandBuffer = null;
            if (EntityManager.HasComponent <PostLoadCommandBuffer>(entity))
            {
                postLoadCommandBuffer = EntityManager.GetComponentData <PostLoadCommandBuffer>(entity);
            }
            else if (EntityManager.HasComponent <SceneEntityReference>(entity))
            {
                var sceneEntity = EntityManager.GetComponentData <SceneEntityReference>(entity).SceneEntity;
                if (EntityManager.HasComponent <PostLoadCommandBuffer>(sceneEntity))
                {
                    postLoadCommandBuffer = EntityManager.GetComponentData <PostLoadCommandBuffer>(sceneEntity);
                }
            }

            if (postLoadCommandBuffer != null)
            {
                postLoadCommandBuffer = (PostLoadCommandBuffer)postLoadCommandBuffer.Clone();
            }
#endif
            return(new AsyncLoadSceneOperation(new AsyncLoadSceneData
            {
                ScenePath = entitiesBinaryPath,
                SceneSize = sceneData.DecompressedFileSize,
                CompressedSceneSize = sceneData.FileSize,
                Codec = sceneData.Codec,
                ExpectedObjectReferenceCount = sceneData.ObjectReferenceCount,
                ResourcesPathObjRefs = resourcesPath,
                EntityManager = dstManager,
                BlockUntilFullyLoaded = blockUntilFullyLoaded,
                Dependencies = dependencies,
#if !UNITY_DISABLE_MANAGED_COMPONENTS
                PostLoadCommandBuffer = postLoadCommandBuffer
#endif
            }));
        }
        AsyncLoadSceneOperation CreateAsyncLoadSceneOperation(EntityManager dstManager, Entity entity, bool blockUntilFullyLoaded)
        {
            var sceneData   = EntityManager.GetComponentData <SceneSectionData>(entity);
            var sectionData = EntityManager.GetComponentData <ResolvedSectionPath>(entity);

            var entitiesBinaryPath = sectionData.ScenePath.ToString();
            var resourcesPath      = sectionData.HybridPath.ToString();

#if !UNITY_DISABLE_MANAGED_COMPONENTS
            PostLoadCommandBuffer postLoadCommandBuffer = null;
            if (EntityManager.HasComponent <PostLoadCommandBuffer>(entity))
            {
                postLoadCommandBuffer = EntityManager.GetComponentData <PostLoadCommandBuffer>(entity);
            }
            else if (EntityManager.HasComponent <SceneEntityReference>(entity))
            {
                var sceneEntity = EntityManager.GetComponentData <SceneEntityReference>(entity).SceneEntity;
                if (EntityManager.HasComponent <PostLoadCommandBuffer>(sceneEntity))
                {
                    postLoadCommandBuffer = EntityManager.GetComponentData <PostLoadCommandBuffer>(sceneEntity);
                }
            }

            if (postLoadCommandBuffer != null)
            {
                postLoadCommandBuffer = (PostLoadCommandBuffer)postLoadCommandBuffer.Clone();
            }
#endif
            return(new AsyncLoadSceneOperation(new AsyncLoadSceneData
            {
                ScenePath = entitiesBinaryPath,
                SceneSize = sceneData.FileSize,
                ExpectedObjectReferenceCount = sceneData.ObjectReferenceCount,
                ResourcesPathObjRefs = resourcesPath,
                EntityManager = dstManager,
                BlockUntilFullyLoaded = blockUntilFullyLoaded,
#if !UNITY_DISABLE_MANAGED_COMPONENTS
                PostLoadCommandBuffer = postLoadCommandBuffer
#endif
            }));
        }