Ejemplo n.º 1
0
    /// <summary>
    /// Restrict the panel's contents to be within the panel's bounds.
    /// </summary>

    public bool RestrictWithinBounds(bool instant)
    {
        Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (restrictByRealBounds && bounds.max.y - bounds.min.y < mPanel.clipRange.w)
        {
            Vector4 realBounds = mPanel.clipRange;
            realBounds.w = bounds.max.y - bounds.min.y;
            realBounds.y = mPanel.clipRange.y - (realBounds.w - mPanel.clipRange.w) * 0.5f;

            constraint = mPanel.CalculateConstrainOffsetByBounds(bounds.min, bounds.max, realBounds);
        }


        if (constraint.magnitude > 0.001f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place

                if (vecOnDragonMode == OnDragonMode.LeftOrRight)
                {
                    Vector3 targetPos = new Vector3();
                    targetPos.x = vecPosOrigen.x;
                    targetPos.y = mTrans.localPosition.y;
                    targetPos.z = mTrans.localPosition.z;
                    SpringPanel.Begin(mPanel.gameObject, targetPos, 13f);
                }
                else
                {
                    SpringPanel.Begin(mPanel.gameObject, mTrans.localPosition + constraint, 13f);
                }

                //SpringPanel.Begin(mPanel.gameObject, vecPosOrigen, 13f);
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);
                mMomentum = Vector3.zero;
                mScroll   = 0f;
            }
            return(true);
        }
        return(false);
    }