Exemplo n.º 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            inputDeps = CopyToCamera(m_cameraQuery, inputDeps);
            var cameras    = m_cameraQuery.GetComponentAccess(EntityManager, ref m_cameraAccessState);
            var cameraData = m_cameraQuery.ToComponentDataArray <CameraComponentData>(Allocator.TempJob);

            for (var i = 0; i < cameraData.Length; ++i)
            {
                var camera = cameras[i];
                cameraData[i] = new CameraComponentData {
                    ProjectionMatrix    = camera.projectionMatrix,
                    WorldToCameraMatrix = camera.worldToCameraMatrix,
                    IsOrthographic      = camera.orthographic,
                    OrthographicSize    = camera.orthographicSize,
                    FieldOfView         = camera.fieldOfView,
                    NearClipPlane       = camera.nearClipPlane,
                    FarClipPlane        = camera.farClipPlane,
                    Aspect = camera.aspect
                };
            }
            m_cameraQuery.CopyFromComponentDataArray(cameraData, out var copyHandle);
            inputDeps = JobHandle.CombineDependencies(inputDeps, copyHandle);
            inputDeps = new CalcCameraCache {
                ScreenSize = new float2(Screen.width, Screen.height)
            }.Schedule(this, inputDeps);
            inputDeps = cameraData.Dispose(inputDeps);
            return(inputDeps);
        }
Exemplo n.º 2
0
        protected override void OnUpdate()
        {
            CopyToCamera(m_cameraQuery);
            var cameras    = m_cameraQuery.GetComponentAccess(EntityManager, ref m_cameraAccessState);
            var cameraData = m_cameraQuery.ToComponentDataArray <CameraComponentData>(Allocator.TempJob);

            for (var i = 0; i < cameraData.Length; ++i)
            {
                var camera = cameras[i];
                cameraData[i] = new CameraComponentData {
                    ProjectionMatrix    = camera.projectionMatrix,
                    WorldToCameraMatrix = camera.worldToCameraMatrix,
                    IsOrthographic      = camera.orthographic,
                    OrthographicSize    = camera.orthographicSize,
                    FieldOfView         = camera.fieldOfView,
                    NearClipPlane       = camera.nearClipPlane,
                    FarClipPlane        = camera.farClipPlane,
                    Aspect = camera.aspect
                };
            }
            m_cameraQuery.CopyFromComponentDataArrayAsync(cameraData, out var copyHandle);
            Dependency = JobHandle.CombineDependencies(Dependency, copyHandle);
            CalcCameraCache(new float2(Screen.width, Screen.height));
            Dependency = cameraData.Dispose(Dependency);
        }