private void manualUpdate() { if (state != TransformerState.Manual) { stateManual(); } var mask = gesture.TransformMask; if ((mask & TransformGesture.TransformType.Scaling) != 0) { targetScale *= gesture.DeltaScale; } if ((mask & TransformGesture.TransformType.Rotation) != 0) { targetRotation = Quaternion.AngleAxis(gesture.DeltaRotation, gesture.RotationAxis) * targetRotation; } if ((mask & TransformGesture.TransformType.Translation) != 0) { targetPosition += gesture.DeltaPosition; } transformMask |= mask; gesture.OverrideTargetPosition(targetPosition); if (!enableSmoothing) { applyValues(); } }
/// <summary> /// Resets the frame delta values. /// </summary> protected void resetValues() { deltaPosition = Vector3.zero; deltaRotation = 0f; deltaScale = 1f; transformMask = 0; }
private void stateManual() { setState(TransformerState.Manual); targetPosition = lastPosition = cachedTransform.position; targetRotation = lastRotation = cachedTransform.rotation; targetScale = lastScale = cachedTransform.localScale; transformMask = TransformGesture.TransformType.None; }
private void applyValues() { if ((transformMask & TransformGesture.TransformType.Scaling) != 0) { cachedTransform.localScale = targetScale; } if ((transformMask & TransformGesture.TransformType.Rotation) != 0) { cachedTransform.rotation = targetRotation; } //if ((transformMask & TransformGesture.TransformType.Translation) != 0) cachedTransform.position = targetPosition; //instead of calling the transform, send target position to drag and drop script? moveObject(); transformMask = TransformGesture.TransformType.None; }
private void applyValues() { if ((transformMask & TransformGesture.TransformType.Scaling) != 0) { cachedTransform.localScale = targetScale; } if ((transformMask & TransformGesture.TransformType.Rotation) != 0) { cachedTransform.rotation = targetRotation; } if ((transformMask & TransformGesture.TransformType.Translation) != 0) { cachedTransform.position = targetPosition; } transformMask = TransformGesture.TransformType.None; }
private void stateIdle() { var prevState = state; setState(TransformerState.Idle); if (enableSmoothing && prevState == TransformerState.Automatic) { transform.position = lastPosition = targetPosition; var newLocalScale = lastScale = targetScale; // prevent recalculating colliders when no scale occurs if (newLocalScale != transform.localScale) { transform.localScale = newLocalScale; } transform.rotation = lastRotation = targetRotation; } transformMask = TransformGesture.TransformType.None; }