/// <summary> /// Continues the elevation. /// </summary> /// <param name="gesture">The current gesture.</param> protected override void OnContinueManipulation(TwoFingerDragGesture gesture) { float elevationScale = 0.25f; Quaternion cameraRotation = Camera.main.transform.rotation; Vector3 rotatedDelta = cameraRotation * gesture.Delta; float elevationAmount = (rotatedDelta.y / Screen.dpi) * elevationScale; transform.Translate(0.0f, elevationAmount, 0.0f); // We cannot move it below the original position. if (transform.localPosition.y < transform.parent.InverseTransformPoint(m_Origin).y) { transform.position = transform.parent.TransformPoint( new Vector3( transform.localPosition.x, transform.parent.InverseTransformPoint(m_Origin).y, transform.localPosition.z)); } GetComponent <SelectionManipulator>().OnElevationChangedScaled( Mathf.Abs(transform.position.y - m_Origin.y)); OnContinueElevationVisualization(transform.position); }
/// <summary> /// Returns true if the transformation can be started for the given gesture. /// </summary> /// <param name="gesture">The current gesture.</param> /// <returns>True if the transformation can be started.</returns> protected override bool CanStartManipulationForGesture(TwoFingerDragGesture gesture) { if (!IsSelected()) { return(false); } if (gesture.TargetObject != null) { return(false); } if (transform.parent.up != Vector3.up && transform.parent.up != Vector3.down) { // Don't allow elevation on vertical planes. return(false); } if (checkLiftToggle() == false) { return(false); } return(true); }
/// <summary> /// Starts the elevation. /// </summary> /// <param name="gesture">The current gesture.</param> protected override void OnStartManipulation(TwoFingerDragGesture gesture) { m_Origin = transform.localPosition; m_Origin.y = transform.InverseTransformPoint(transform.parent.position).y; m_Origin = transform.TransformPoint(m_Origin); OnStartElevationVisualization(m_Origin, transform.position); }
private void OnGestureStarted(TwoFingerDragGesture gesture) { if (m_IsManipulating) { return; } if (CanStartManipulationForGesture(gesture)) { m_IsManipulating = true; gesture.onUpdated += OnUpdated; gesture.onFinished += OnFinished; OnStartManipulation(gesture); } }
private void OnUpdated(TwoFingerDragGesture gesture) { if (!m_IsManipulating) { return; } // Can only transform selected Items. if (ManipulationSystem.Instance.SelectedObject != gameObject) { m_IsManipulating = false; OnEndManipulation(gesture); return; } OnContinueManipulation(gesture); }
/// <summary> /// Returns true if the transformation can be started for the given gesture. /// </summary> /// <param name="gesture">The current gesture.</param> /// <returns>True if the transformation can be started.</returns> protected override bool CanStartManipulationForGesture(TwoFingerDragGesture gesture) { if (!IsSelected()) { return(false); } if (gesture.TargetObject != null) { return(false); } gameObject.GetComponent <PhotonView>().RequestOwnership(); if (transform.parent.up != Vector3.up && transform.parent.up != Vector3.down) { // Don't allow elevation on vertical planes. return(false); } return(true); }
/// <summary> /// Finishes the elevation. /// </summary> /// <param name="gesture">The current gesture.</param> protected override void OnEndManipulation(TwoFingerDragGesture gesture) { OnEndElevationVisualization(); }
private void OnFinished(TwoFingerDragGesture gesture) { m_IsManipulating = false; OnEndManipulation(gesture); }
/// <summary> /// Function called when the manipulation is ended. /// </summary> /// <param name="gesture">The current gesture.</param> protected virtual void OnEndManipulation(TwoFingerDragGesture gesture) { // Optional override. }
/// <summary> /// Returns true if the manipulation can be started for the given gesture. /// </summary> /// <param name="gesture">The current gesture.</param> /// <returns>True if the manipulation can be started.</returns> protected virtual bool CanStartManipulationForGesture(TwoFingerDragGesture gesture) { return(false); }