protected override void Manipulate() { if (_axis == Axis.Y) { float angle = YAngle(); float deltaAngle = angle - _priorAngle; TargetTransform.Rotate(new Vector3(0, deltaAngle, 0), Space.World); _priorAngle = angle; } else if (_axis == Axis.X) { float angle = XAngle(); float deltaAngle = angle - _priorAngle; if (_rotateAxis == RotateAxis.LocalX) { TargetTransform.Rotate(new Vector3(deltaAngle, 0, 0), Space.Self); } else if (_rotateAxis == RotateAxis.LocalZ) { TargetTransform.Rotate(new Vector3(0, 0, deltaAngle), Space.Self); } else if (_rotateAxis == RotateAxis.Screen) { Vector3 cameraDirection = _eventCamera.EventCameraRef.transform.position - TargetTransform.position; Vector3 crossDirection = Vector3.Cross(cameraDirection, Vector3.up); TargetTransform.RotateAround(TargetTransform.position, crossDirection, deltaAngle); } _priorAngle = angle; } }
/// <summary> /// Nudges the transform in the specified rotation. /// </summary> /// <param name="rotation"> /// The direction to nudge in. /// </param> public void Nudge(NudgeRotation rotation) { // Determine angle float angle = (rotation == NudgeRotation.Left ? -rotationAmount : rotationAmount); // Update the rotation TargetTransform.Rotate(upDirection.ToVector(), angle, space); }