/// <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 override bool CanStartManipulationForGesture(PinchGesture gesture)
        {
            if (!IsSelected())
            {
                return(false);
            }

            if (gesture.TargetObject != null)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
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 override bool CanStartManipulationForGesture(PinchGesture gesture)
        {
            if (!IsSelected())
            {
                return(false);
            }

            if (gesture.TargetObject != null)
            {
                return(false);
            }
            gameObject.GetComponent <PhotonView>().RequestOwnership();
            return(true);
        }
Exemple #3
0
        private void OnGestureStarted(PinchGesture gesture)
        {
            if (m_IsManipulating)
            {
                return;
            }

            if (CanStartManipulationForGesture(gesture))
            {
                m_IsManipulating    = true;
                gesture.onUpdated  += OnUpdated;
                gesture.onFinished += OnFinished;
                OnStartManipulation(gesture);
            }
        }
        /// <summary>
        /// Continues the scaling of the object.
        /// </summary>
        /// <param name="gesture">The current gesture.</param>
        protected override void OnContinueManipulation(PinchGesture gesture)
        {
            m_CurrentScaleRatio += k_Sensitivity * GestureTouchesUtility.PixelsToInches(gesture.GapDelta);

            float currentScale = m_CurrentScale;

            transform.localScale = new Vector3(currentScale, currentScale, currentScale);

            // If we've tried to scale too far beyond the limit, then cancel the gesture
            // to snap back within the scale range.
            if (m_CurrentScaleRatio < -k_ElasticRatioLimit ||
                m_CurrentScaleRatio > (1.0f + k_ElasticRatioLimit))
            {
                gesture.Cancel();
            }
        }
Exemple #5
0
        private void OnUpdated(PinchGesture gesture)
        {
            if (!m_IsManipulating)
            {
                return;
            }

            // Can only transform selected Items.
            if (ManipulationSystem.Instance.SelectedObject != gameObject)
            {
                m_IsManipulating = false;
                OnEndManipulation(gesture);
                return;
            }

            OnContinueManipulation(gesture);
        }
 /// <summary>
 /// Finishes the scaling of the object.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected override void OnEndManipulation(PinchGesture gesture)
 {
     m_IsScaling = false;
 }
 /// <summary>
 /// Recalculates the current scale ratio in case local scale, min or max scale were changed.
 /// </summary>
 /// <param name="gesture">The gesture that started this transformation.</param>
 protected override void OnStartManipulation(PinchGesture gesture)
 {
     m_IsScaling         = true;
     m_CurrentScaleRatio = (transform.localScale.x - MinScale) / ScaleDelta;
 }
Exemple #8
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(PinchGesture gesture)
 {
     return(false);
 }
Exemple #9
0
 private void OnFinished(PinchGesture gesture)
 {
     m_IsManipulating = false;
     OnEndManipulation(gesture);
 }
Exemple #10
0
 /// <summary>
 /// Function called when the manipulation is ended.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected virtual void OnEndManipulation(PinchGesture gesture)
 {
     // Optional override.
 }