コード例 #1
0
ファイル: LeanScale.cs プロジェクト: ruanderzi/appRA-Fisica
        protected virtual void Update()
        {
            // pega os dedos que queremos usar
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // calcula pinchScale e verifique se ela é válida
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            if (pinchScale != 1.0f)
            {
                // realiza a translacao se esta for uma escala relativa
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                // realiza o dimensionamento
                Scale(transform.localScale * pinchScale);
            }
        }
コード例 #2
0
        protected virtual void Update()
        {
            // If we require a selectable and it isn't selected, cancel scaling
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            // Calculate the scaling values based on these fingers
            var pinchScale   = LeanGesture.GetPinchScale(fingers, WheelSensitivity);
            var screenCenter = LeanGesture.GetScreenCenter(fingers);

            int layerMask = ~LayerMask.GetMask("Ignore Raycast");

            if (Input.GetMouseButton(0))
            {
                Ray        raycast = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit raycastHit;
                if (Physics.Raycast(raycast, out raycastHit, Mathf.Infinity, layerMask, QueryTriggerInteraction.UseGlobal))
                {
                    Debug.Log("Ray hit occurred!");
                    // Perform the scaling
                    Scale(pinchScale, screenCenter, raycastHit);
                }
            }
        }
コード例 #3
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingersOrClear(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            pinch = pinchScale;

            if (pinchScale > 0.0f)
            {
                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                // Perform the scaling
                Scale(transform.localScale * pinchScale);
                Debug.Log("Pinch scale:" + pinchScale);
            }
        }
コード例 #4
0
        protected virtual void Update()
        {
            // Получить пальцы, которые мы хотим использовать
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Рассчитайтываем масштаб щепотки и убедитесь, что он действителен
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            if (pinchScale != 1.0f)
            {
                // Выполните перевод, если это относительная шкала
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                // Выполнить масштабирование
                Scale(transform.localScale * pinchScale);
            }
        }
コード例 #5
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            //if (pinchScale != 1.0f)
            //{
            //	// Perform the translation if this is a relative scale
            //	if (Relative == true)
            //	{
            //		var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

            //		if (transform is RectTransform)
            //		{
            //			TranslateUI(pinchScale, pinchScreenCenter);
            //		}
            //		else
            //		{
            //			Translate(pinchScale, pinchScreenCenter);
            //		}
            //	}

            // Perform the scaling
            Scale(transform.localScale * pinchScale);
            //}
        }
コード例 #6
0
        protected virtual void Update()
        {
            // If we require a selectable and it isn't selected, cancel scaling
//			if (RequiredSelectable != null && RequiredSelectable.IsSelected == false && !ModelManager._instance)
//			{
//				return;
//			}
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }
            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            if (fingers != null)
            {
                if (fingers.Count >= 2)
                {
                    float dis = Vector2.Distance(fingers [0].ScreenPosition, fingers [1].ScreenPosition);
                    //Debug.Log ("-----distance :" + dis);
                    if (dis < 300)
                    {
                        return;
                    }
                }
            }
            // Calculate the scaling values based on these fingers
            var scale        = LeanGesture.GetPinchScale(fingers, WheelSensitivity);
            var screenCenter = LeanGesture.GetScreenCenter(fingers);

            // Perform the scaling
            Scale(scale, screenCenter);
        }
コード例 #7
0
 public void OnGesture(List <LeanFinger> fingers)
 {
     Debug.Log("Gesture with " + fingers.Count + " finger(s)");
     Debug.Log("    pinch scale: " + LeanGesture.GetPinchScale(fingers));
     Debug.Log("    twist degrees: " + LeanGesture.GetTwistDegrees(fingers));
     Debug.Log("    twist radians: " + LeanGesture.GetTwistRadians(fingers));
     Debug.Log("    screen delta: " + LeanGesture.GetScreenDelta(fingers));
 }
コード例 #8
0
        protected virtual void Update()
        {
            // Store
            var oldScale = transform.localPosition;

            if (_localScale.Equals(Vector3.zero))
            {
                _localScale = transform.localScale;                                   //
            }
            // Get the fingers we want to use
            var fingers = Use.GetFingers();

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers);
            var newScale   = transform.localScale * pinchScale;

            if (newScale.x > _localScale.x * MAX_SCALE || newScale.x < _localScale.x * MIN_SCALE)
            {
                pinchScale = 1f;
            }

            if (pinchScale != 1.0f)
            {
                pinchScale = Mathf.Pow(pinchScale, Sensitivity);

                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                transform.localScale *= pinchScale;

                remainingScale += transform.localPosition - oldScale;
            }

            // Get t value
            var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);

            // Dampen remainingDelta
            var newRemainingScale = Vector3.Lerp(remainingScale, Vector3.zero, factor);

            // Shift this transform by the change in delta
            transform.localPosition = oldScale + remainingScale - newRemainingScale;

            // Update remainingDelta with the dampened value
            remainingScale = newRemainingScale;
        }
コード例 #9
0
        protected virtual void Update()
        {
            // Store
            var oldScale = transform.localPosition;

            // Get the fingers we want to use
            var fingers = Use.GetFingers();

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers);

            if (pinchScale != 1.0f)
            {
                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                transform.localScale *= pinchScale;
                float currentScale = transform.localScale.x;
                if (currentScale > 1.0f)
                {
                    transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                }
                else if (currentScale < 0.1f)
                {
                    transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                }

                remainingScale += transform.localPosition - oldScale;
            }

            // Get t value
            var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);

            // Dampen remainingDelta
            var newRemainingScale = Vector3.Lerp(remainingScale, Vector3.zero, factor);

            // Shift this transform by the change in delta
            transform.localPosition = oldScale + remainingScale - newRemainingScale;

            // Update remainingDelta with the dampened value
            remainingScale = newRemainingScale;
        }
コード例 #10
0
        protected virtual void Update()
        {
            // Store
            var oldScale     = transform.localPosition;
            var initialScale = transform.localScale;
            // Get the fingers we want to use
            var fingers = Use.GetFingers();

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers);

            if (pinchScale != 1.0f)
            {
                pinchScale = Mathf.Pow(pinchScale, Sensitivity);

                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }
                Vector3 m_scale = initialScale * pinchScale;

                m_scale.x            = Mathf.Clamp(m_scale.x, m_minScale, m_maxScale);
                m_scale.y            = Mathf.Clamp(m_scale.y, m_minScale, m_maxScale);
                m_scale.z            = Mathf.Clamp(m_scale.z, m_minScale, m_maxScale);
                transform.localScale = m_scale;

                remainingScale += transform.localPosition - oldScale;
            }

            // Get t value
            var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);

            // Dampen remainingDelta
            var newRemainingScale = Vector3.Lerp(remainingScale, Vector3.zero, factor);

            // Shift this transform by the change in delta
            transform.localPosition = oldScale + remainingScale - newRemainingScale;

            // Update remainingDelta with the dampened value
            remainingScale = newRemainingScale;
        }
コード例 #11
0
ファイル: LeanScale.cs プロジェクト: Tardis-x/Bigger-Inside
        protected virtual void Update()
        {
            if (Camera.main == null)
            {
                return;
            }

            // Get the fingers we want to use
            var fingers =
                LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            var newScale = transform.localScale * pinchScale;

            if (newScale.x < ScaleMin.x || newScale.x > ScaleMax.x)
            {
                return;
            }

            if (pinchScale > 0.0f)
            {
                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (!Physics.Raycast(Camera.main.ScreenPointToRay(pinchScreenCenter)))
                    {
                        return;
                    }

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                // Perform the scaling
                Scale(transform.localScale * pinchScale);
            }
        }
コード例 #12
0
ファイル: LeanScale.cs プロジェクト: shailendra60/Shailendra-
        protected virtual void Update()
        {
            // If we require a selectable and it isn't selected, cancel scaling
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            // Calculate the scaling values based on these fingers
            var scale        = LeanGesture.GetPinchScale(fingers);
            var screenCenter = LeanGesture.GetScreenCenter(fingers);

            // Perform the scaling
            Scale(scale, screenCenter);
        }
コード例 #13
0
        // Update is called once per frame
        void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount,
                                                    RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, 0);

            if (pinchScale > 0.0f)
            {
                var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                Translate(pinchScale, pinchScreenCenter);
            }


            // Perform the scaling
            Scale(transform.localScale * pinchScale);
        }
コード例 #14
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingersOrClear(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            if (pinchScale > 0.0f)
            {
                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                if (Demo01Management.instance.active3D == false)
                {
                    // Perform the scaling
                    Scale(transform.localScale * pinchScale);
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                transform.localScale = ScaleMin;
            }
        }
コード例 #15
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Get pinch
            var pinch = Scale == ScaleType.PinchRatio == true?LeanGesture.GetPinchRatio(fingers, WheelSensitivity) : LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            // Ignore?
            if (pinch == 1.0f)
            {
                return;
            }

            // This gives you a 0 based pinch value, allowing usage with translation and rotation
            if (Scale == ScaleType.PinchShift)
            {
                pinch -= 1.0f;
            }

            // Call events
            if (OnPinch != null)
            {
                OnPinch.Invoke(pinch);
            }
        }
コード例 #16
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = Use.GetFingers();

            if (fingers.Count > 1 && onPinch != null)
            {
                switch (Coordinate)
                {
                case CoordinateType.OneBasedScale:
                {
                    var scale = LeanGesture.GetPinchScale(fingers);

                    scale = Mathf.Pow(scale, Multiplier);

                    onPinch.Invoke(scale);
                }
                break;

                case CoordinateType.OneBasedRatio:
                {
                    var ratio = LeanGesture.GetPinchRatio(fingers);

                    ratio = Mathf.Pow(ratio, Multiplier);

                    onPinch.Invoke(ratio);
                }
                break;

                case CoordinateType.ZeroBasedScale:
                {
                    var scale = LeanGesture.GetPinchScale(fingers);

                    scale = (scale - 1.0f) * Multiplier;

                    onPinch.Invoke(scale);
                }
                break;

                case CoordinateType.ZeroBasedRatio:
                {
                    var ratio = LeanGesture.GetPinchRatio(fingers);

                    ratio = (ratio - 1.0f) * Multiplier;

                    onPinch.Invoke(ratio);
                }
                break;

                case CoordinateType.ZeroBasedDistance:
                {
                    var oldDistance = LeanGesture.GetLastScaledDistance(fingers, LeanGesture.GetLastScreenCenter(fingers));
                    var newDistance = LeanGesture.GetScaledDistance(fingers, LeanGesture.GetScreenCenter(fingers));
                    var movement    = (newDistance - oldDistance) * Multiplier;

                    onPinch.Invoke(movement);
                }
                break;
                }
            }
        }
コード例 #17
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = Use.GetFingers();

            // Get pinch
            var pinch = Coordinate == CoordinateType.OneBasedReciprocal == true?LeanGesture.GetPinchRatio(fingers) : LeanGesture.GetPinchScale(fingers);

            // Ignore?
            if (pinch == 1.0f)
            {
                return;
            }

            // This gives you a 0 based pinch value, allowing usage with translation and rotation
            if (Coordinate == CoordinateType.ZeroBased)
            {
                pinch -= 1.0f; pinch *= Multiplier;
            }
            else
            {
                pinch = Mathf.Pow(pinch, Multiplier);
            }

            // Call events
            if (onPinch != null)
            {
                onPinch.Invoke(pinch);
            }
        }