// ------------------------------------------------------------------------------------------- public void Update(float progress) { if (_invalidated) { return; } if (_reverse) { progress = 1 - progress; } TweenFuncs.SetLocalPosition(_transform, _path.Evaluate(progress)); }
// ------------------------------------------------------------------------------------------- public void Update(float progress) { if (_invalidated || _target == null) { return; } Vector3 v; if (_move) { v = TweenFuncs.GetLocalPosition(_target); v.x = _startX + ((_endX - _startX) * progress); v.y = _startY + ((_endY - _startY) * progress); TweenFuncs.SetLocalPosition(_target, v); } if (_scale) { v = _target.localScale; v.x = _startScaleX + ((_endScaleX - _startScaleX) * progress); v.y = _startScaleY + ((_endScaleY - _startScaleY) * progress); _target.localScale = v; } if (_rotate) { v = _target.localEulerAngles; v.z = _startRotation + ((_endRotation - _startRotation) * progress); _target.localEulerAngles = v; } if (_transformAroundPoint) { if (_transformInParent && _target.parent != null) { Vector3 newWorldCoords = _target.TransformPoint(_localPoint); Vector3 newParentCoords = _target.parent.InverseTransformPoint(newWorldCoords); Vector3 position = TweenFuncs.GetLocalPosition(_target); position.x += _parentCoords.x - newParentCoords.x; position.y += _parentCoords.y - newParentCoords.y; TweenFuncs.SetLocalPosition(_target, position); } else { Vector3 newWorldCoords = _target.TransformPoint(_localPoint); Vector3 position = _target.position; position.x += _worldCoords.x - newWorldCoords.x; position.x += _worldCoords.x - newWorldCoords.x; _target.position = position; } } }
// ------------------------------------------------------------------------------------------- /// <summary> /// Moves the target from the specified position to its current position. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public Tween MoveFrom(float x, float y) { Transform t = GetTransform(); if (t != null) { TweenTransform p = new TweenTransform(t); Vector3 currentPos = TweenFuncs.GetLocalPosition(t); p.Move(x, y, currentPos.x, currentPos.y); _procedures.Add(p); } else { From("x", x); From("y", y); } return(this); }