Пример #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_InitialTransformGroup.GetTransformAccessArray();
            var entities   = m_InitialTransformGroup.GetEntityArray();

            var transformStashes   = new NativeArray <TransformStash>(transforms.length, Allocator.TempJob);
            var stashTransformsJob = new StashTransforms
            {
                transformStashes = transformStashes
            };

            var stashTransformsJobHandle = stashTransformsJob.Schedule(transforms, inputDeps);

            var copyTransformsJob = new CopyTransforms
            {
                positions        = m_Positions,
                rotations        = m_Rotations,
                localPositions   = m_LocalPositions,
                localRotations   = m_LocalRotations,
                transformStashes = transformStashes,
                entities         = entities
            };

            var copyTransformsJobHandle = copyTransformsJob.Schedule(transformStashes.Length, 64, stashTransformsJobHandle);

            var removeComponentsJob = new RemoveCopyInitialTransformFromGameObjectComponent
            {
                entities            = entities,
                entityCommandBuffer = m_EndFrameBarrier.CreateCommandBuffer()
            };
            var removeComponentsJobHandle = removeComponentsJob.Schedule(copyTransformsJobHandle);

            return(removeComponentsJobHandle);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_InitialTransformGroup.GetTransformAccessArray();
            var entities   = m_InitialTransformGroup.ToEntityArray(Allocator.TempJob);

            var transformStashes   = new NativeArray <TransformStash>(transforms.length, Allocator.TempJob);
            var stashTransformsJob = new StashTransforms
            {
                transformStashes = transformStashes
            };

            var stashTransformsJobHandle = stashTransformsJob.Schedule(transforms, inputDeps);

            var copyTransformsJob = new CopyTransforms
            {
                transformStashes = transformStashes,
            };

            var copyTransformsJobHandle = copyTransformsJob.Schedule(m_InitialTransformGroup, stashTransformsJobHandle);

            var removeComponentsJob = new RemoveCopyInitialTransformFromGameObjectComponent
            {
                entities            = entities,
                entityCommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer()
            };
            var removeComponentsJobHandle = removeComponentsJob.Schedule(copyTransformsJobHandle);

            m_EntityCommandBufferSystem.AddJobHandleForProducer(removeComponentsJobHandle);
            return(removeComponentsJobHandle);
        }
Пример #3
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_TransformGroup.GetTransformAccessArray();
            var entities   = m_TransformGroup.GetEntityArray();

            var transformStashes   = new NativeArray <TransformStash>(transforms.Length, Allocator.TempJob);
            var stashTransformsJob = new StashTransforms
            {
                transformStashes = transformStashes
            };

            var stashTransformsJobHandle = stashTransformsJob.Schedule(transforms, inputDeps);

            var copyTransformsJob = new CopyTransforms
            {
                positions        = m_Positions,
                rotations        = m_Rotations,
                localPositions   = m_LocalPositions,
                localRotations   = m_LocalRotations,
                transformStashes = transformStashes,
                entities         = entities
            };

            return(copyTransformsJob.Schedule(transformStashes.Length, 64, stashTransformsJobHandle));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms        = m_TransformGroup.GetTransformAccessArray();
            var copyTransformsJob = new CopyTransforms
            {
                LocalToWorlds = m_TransformGroup.ToComponentDataArray <LocalToWorld>(Allocator.TempJob, out inputDeps),
            };

            return(copyTransformsJob.Schedule(transforms, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_TransformGroup.GetTransformAccessArray();
            var entities   = m_TransformGroup.ToEntityArray(Allocator.TempJob);

            var copyTransformsJob = new CopyTransforms
            {
                LocalToWorlds = GetComponentDataFromEntity <LocalToWorld>(true),
                entities      = entities
            };

            return(copyTransformsJob.Schedule(transforms, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_TransformGroup.GetTransformAccessArray();
            var entities   = m_TransformGroup.GetEntityArray();

            var copyTransformsJob = new CopyTransforms
            {
                positions = GetComponentDataFromEntity <Position>(true),
                rotations = GetComponentDataFromEntity <Rotation>(true),
                entities  = entities
            };

            return(copyTransformsJob.Schedule(transforms, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms = m_TransformGroup.GetTransformAccessArray();
            var entities   = m_TransformGroup.GetEntityArray();

            var copyTransformsJob = new CopyTransforms
            {
                positions = m_Positions,
                rotations = m_Rotations,
                entities  = entities
            };

            var resultDeps = copyTransformsJob.Schedule(transforms, inputDeps);

            return(resultDeps);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var transforms         = m_TransformGroup.GetTransformAccessArray();
            var transformStashes   = new NativeArray <TransformStash>(transforms.length, Allocator.TempJob);
            var stashTransformsJob = new StashTransforms
            {
                transformStashes = transformStashes
            };

            var stashTransformsJobHandle = stashTransformsJob.Schedule(transforms, inputDeps);

            var copyTransformsJob = new CopyTransforms
            {
                transformStashes = transformStashes,
            };

            return(copyTransformsJob.Schedule(m_TransformGroup, stashTransformsJobHandle));
        }
Пример #9
0
        void CopyToCamera(EntityQuery query)
        {
            query.SetChangedVersionFilter(typeof(LocalToWorld));
            var changedEntities = query.CalculateEntityCount();

            query.ResetFilter();
            if (changedEntities == 0)
            {
                Dependency = query.GetChangedTransformFromEntity(this, ref m_changedTransforms, Dependency);
                Dependency = query.CopyFromChangedComponentData(this, ref m_changedTransforms, Dependency);
                return;
            }
            var entities = query.ToEntityArrayAsync(Allocator.TempJob, out var toEntityHandle);

            Dependency = JobHandle.CombineDependencies(Dependency, toEntityHandle);
            Dependency = new CopyTransforms {
                LocalToWorldFromEntity = GetComponentDataFromEntity <LocalToWorld>(true),
                entities = entities
            }.Schedule(query.GetTransformAccessArray(), Dependency);
        }
Пример #10
0
    public override void Update()
    {
        //While the game is not playing - Editor / Set up functionality
        if (!Application.isPlaying)
        {
            //Copy Transform data to Vectors
            #region Set Vector Data

            Vector3 retrievedVector3 = Vector3.zero;

            if (TweenTransformProperty == TransformTypes.LocalRotation)
            {
                retrievedVector3 = new Vector3(gameObject.transform.localEulerAngles.x,
                                               gameObject.transform.localEulerAngles.y,
                                               gameObject.transform.localEulerAngles.z);
            }

            else if (TweenTransformProperty == TransformTypes.Rotation)
            {
                retrievedVector3 = new Vector3(gameObject.transform.eulerAngles.x,
                                               gameObject.transform.eulerAngles.y,
                                               gameObject.transform.eulerAngles.z);
            }

            else if (TweenTransformProperty == TransformTypes.LocalPosition)
            {
                retrievedVector3 = new Vector3(gameObject.transform.localPosition.x,
                                               gameObject.transform.localPosition.y,
                                               gameObject.transform.localPosition.z);
            }

            else if (TweenTransformProperty == TransformTypes.Position)
            {
                retrievedVector3 = new Vector3(gameObject.GetComponent <RectTransform>().anchoredPosition.x,
                                               gameObject.GetComponent <RectTransform>().anchoredPosition.y,
                                               0);
            }

            else if (TweenTransformProperty == TransformTypes.Scale)
            {
                retrievedVector3 = new Vector3(gameObject.transform.localScale.x,
                                               gameObject.transform.localScale.y,
                                               gameObject.transform.localScale.z);
            }


            if (CopyTransformTo != CopyTransforms.None)
            {
                if (CopyTransformTo == CopyTransforms.StartingVector)
                {
                    startingVector = retrievedVector3;
                }
                else if (CopyTransformTo == CopyTransforms.EndingVector)
                {
                    endVector = retrievedVector3;
                }
                else if (CopyTransformTo == CopyTransforms.DefaultVector)
                {
                    defaultVector = retrievedVector3;
                }

                CopyTransformTo = CopyTransforms.None;
            }
            #endregion

            #region Set Transform Data
            //Copy Vector Data to Transforms
            if (SetTransformTo != SetTransforms.None)
            {
                if (SetTransformTo == SetTransforms.StartingVector)
                {
                    if (TweenTransformProperty == TransformTypes.LocalRotation)
                    {
                        gameObject.transform.localEulerAngles = startingVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Rotation)
                    {
                        gameObject.transform.eulerAngles = startingVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.LocalPosition)
                    {
                        gameObject.transform.localPosition = startingVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Position)
                    {
                        gameObject.GetComponent <RectTransform>().anchoredPosition = startingVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Scale)
                    {
                        gameObject.transform.localScale = startingVector;
                    }
                }
                else if (SetTransformTo == SetTransforms.EndingVector)
                {
                    if (TweenTransformProperty == TransformTypes.LocalRotation)
                    {
                        gameObject.transform.localEulerAngles = endVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Rotation)
                    {
                        gameObject.transform.eulerAngles = endVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.LocalPosition)
                    {
                        gameObject.transform.localPosition = endVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Position)
                    {
                        gameObject.GetComponent <RectTransform>().anchoredPosition = endVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Scale)
                    {
                        gameObject.transform.localScale = endVector;
                    }
                }
                else if (SetTransformTo == SetTransforms.DefaultVector)
                {
                    if (TweenTransformProperty == TransformTypes.LocalRotation)
                    {
                        gameObject.transform.localEulerAngles = defaultVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Rotation)
                    {
                        gameObject.transform.eulerAngles = defaultVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.LocalPosition)
                    {
                        gameObject.transform.localPosition = defaultVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Position)
                    {
                        gameObject.GetComponent <RectTransform>().anchoredPosition = defaultVector;
                    }

                    else if (TweenTransformProperty == TransformTypes.Scale)
                    {
                        gameObject.transform.localScale = defaultVector;
                    }
                }

                SetTransformTo = SetTransforms.None;
            }
            #endregion

            return;
        }

        //Call Base
        base.Update();

        //Action to carry out
        if (!isPlaying || !delayOver)
        {
            return;
        }

        UpdateTransformProperty();
    }