Author Topic: UIDragObject Problems in NGUI 3.7.2  (Read 4497 times)

me

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
UIDragObject Problems in NGUI 3.7.2
« on: September 22, 2014, 04:03:35 AM »
Hello guys, I had a problem when i use UIDragObject Component in NGUI 3.7.2 .

My default resolution is 960*640. It only woks well in 960*640. The drag object's left can match screen's left.

But when i convert resolution to 800*480 , the problem appears. The drag object's left cannot match screen's left any more.

It works well in the old NGUI editions.

I have no idea how it becomes so. Please help me !!! Thanks ~



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragObject Problems in NGUI 3.7.2
« Reply #1 on: September 22, 2014, 10:17:55 AM »
What is your UIRoot's configuration?

me

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UIDragObject Problems in NGUI 3.7.2
« Reply #2 on: September 23, 2014, 01:05:54 AM »
What is your UIRoot's configuration?


Thank you first !

my UIRoot's configuration is ConstrainedOnMobiles, 960*640, Content Height Fit is select.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragObject Problems in NGUI 3.7.2
« Reply #3 on: September 23, 2014, 12:08:25 PM »
Change UIPanel's ConstrainTargetToBounds() function on line 1704 to this:
  1.         public bool ConstrainTargetToBounds (Transform target, ref Bounds targetBounds, bool immediate)
  2.         {
  3.                 Vector3 min = targetBounds.min;
  4.                 Vector3 max = targetBounds.max;
  5.  
  6.                 float ps = 1f;
  7.  
  8.                 if (mClipping == UIDrawCall.Clipping.None)
  9.                 {
  10.                         UIRoot rt = root;
  11.                         if (rt != null) ps = rt.pixelSizeAdjustment;
  12.                 }
  13.  
  14.                 if (ps != 1f)
  15.                 {
  16.                         min /= ps;
  17.                         max /= ps;
  18.                 }
  19.  
  20.                 Vector3 offset = CalculateConstrainOffset(min, max) * ps;
  21.  
  22.                 if (offset.sqrMagnitude > 0f)
  23.                 {
  24.                         if (immediate)
  25.                         {
  26.                                 target.localPosition += offset;
  27.                                 targetBounds.center += offset;
  28.                                 SpringPosition sp = target.GetComponent<SpringPosition>();
  29.                                 if (sp != null) sp.enabled = false;
  30.                         }
  31.                         else
  32.                         {
  33.                                 SpringPosition sp = SpringPosition.Begin(target.gameObject, target.localPosition + offset, 13f);
  34.                                 sp.ignoreTimeScale = true;
  35.                                 sp.worldSpace = false;
  36.                         }
  37.                         return true;
  38.                 }
  39.                 return false;
  40.         }

me

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UIDragObject Problems in NGUI 3.7.2
« Reply #4 on: September 23, 2014, 09:45:16 PM »
Change UIPanel's ConstrainTargetToBounds() function on line 1704 to this:
  1.         public bool ConstrainTargetToBounds (Transform target, ref Bounds targetBounds, bool immediate)
  2.         {
  3.                 Vector3 min = targetBounds.min;
  4.                 Vector3 max = targetBounds.max;
  5.  
  6.                 float ps = 1f;
  7.  
  8.                 if (mClipping == UIDrawCall.Clipping.None)
  9.                 {
  10.                         UIRoot rt = root;
  11.                         if (rt != null) ps = rt.pixelSizeAdjustment;
  12.                 }
  13.  
  14.                 if (ps != 1f)
  15.                 {
  16.                         min /= ps;
  17.                         max /= ps;
  18.                 }
  19.  
  20.                 Vector3 offset = CalculateConstrainOffset(min, max) * ps;
  21.  
  22.                 if (offset.sqrMagnitude > 0f)
  23.                 {
  24.                         if (immediate)
  25.                         {
  26.                                 target.localPosition += offset;
  27.                                 targetBounds.center += offset;
  28.                                 SpringPosition sp = target.GetComponent<SpringPosition>();
  29.                                 if (sp != null) sp.enabled = false;
  30.                         }
  31.                         else
  32.                         {
  33.                                 SpringPosition sp = SpringPosition.Begin(target.gameObject, target.localPosition + offset, 13f);
  34.                                 sp.ignoreTimeScale = true;
  35.                                 sp.worldSpace = false;
  36.                         }
  37.                         return true;
  38.                 }
  39.                 return false;
  40.         }

Perfect !!! You are so cool ! Thank you very much !