예제 #1
0
 /// <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);
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
        private void OnGestureStarted(TwoFingerDragGesture gesture)
        {
            if (m_IsManipulating)
            {
                return;
            }

            if (CanStartManipulationForGesture(gesture))
            {
                m_IsManipulating    = true;
                gesture.onUpdated  += OnUpdated;
                gesture.onFinished += OnFinished;
                OnStartManipulation(gesture);
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        /// <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);
            }

            return(true);
        }
예제 #6
0
 /// <summary>
 /// Finishes the elevation.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected override void OnEndManipulation(TwoFingerDragGesture gesture)
 {
     OnEndElevationVisualization();
 }
예제 #7
0
 private void OnFinished(TwoFingerDragGesture gesture)
 {
     m_IsManipulating = false;
     OnEndManipulation(gesture);
 }
예제 #8
0
 /// <summary>
 /// Function called when the manipulation is ended.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected virtual void OnEndManipulation(TwoFingerDragGesture gesture)
 {
     // Optional override.
 }
예제 #9
0
 /// <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);
 }