Esempio n. 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);
 }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
 /// <summary>
 /// Finishes the elevation.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected override void OnEndManipulation(TwoFingerDragGesture gesture)
 {
     OnEndElevationVisualization();
 }
Esempio n. 7
0
 private void OnFinished(TwoFingerDragGesture gesture)
 {
     m_IsManipulating = false;
     OnEndManipulation(gesture);
 }
Esempio n. 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.
 }
Esempio n. 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);
 }