Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: arandra on May 23, 2013, 01:26:14 AM

Title: UIDraggablePanel::SetDragAmount
Post by: arandra on May 23, 2013, 01:26:14 AM
could you fix glow things?


   public void SetDragAmount (float x, float y, bool updateScrollbars)
   {
      DisableSpring();

      Bounds b = bounds;
      if (b.min.x == b.max.x || b.min.y == b.max.y) return;
      Vector4 cr = mPanel.clipRange;

      float hx = cr.z * 0.5f;
      float hy = cr.w * 0.5f;
      float left = b.min.x + hx;
      float right = b.max.x - hx;
      float bottom = b.min.y + hy;
      float top = b.max.y - hy;

      if (mPanel.clipping == UIDrawCall.Clipping.SoftClip)
      {
         left -= mPanel.clipSoftness.x;
         right += mPanel.clipSoftness.x;
         bottom -= mPanel.clipSoftness.y;
         top += mPanel.clipSoftness.y;
      }

      // Calculate the offset based on the scroll value
      float ox = Mathf.Lerp(left, right, x);
      float oy = Mathf.Lerp(top, bottom, y);

      // Update the position
      if (!updateScrollbars)
      {
         Vector3 pos = mTrans.localPosition;
         if (scale.x != 0f) pos.x += cr.x - ox;
         if (scale.y != 0f) pos.y += cr.y - oy;
         mTrans.localPosition = pos;
      }

      // Update the clipping offset
      if (scale.x != 0f) cr.x = ox;
      if (scale.y != 0f) cr.y = oy;
      mPanel.clipRange = cr;

      // Update the scrollbars, reflecting this change
      if (updateScrollbars) UpdateScrollbars(false);
   }
Title: Re: UIDraggablePanel::SetDragAmount
Post by: ArenMook on May 23, 2013, 12:12:40 PM
The first one is a nice typo, surprising no one has noticed it before. The second one -- why check for this? It's the position you're adjusting.