Author Topic: Small Feature Requests  (Read 2053 times)

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Small Feature Requests
« on: June 09, 2014, 02:48:59 PM »
Just a couple small requests:

1) Editor-only Anchors - I've been making better use of the anchoring system lately and I really like it. Once objects are set up properly, making layout changes is incredibly easy. The only thing I'd like to see different is the ability to completely disable anchoring at runtime. I know they can be set to "OnEnable", but I only use the anchoring in the Editor and I've actually had it cause some small problems with updating anchors OnEnable. Sometimes I want a objects to be positioned or sized based on other objects that they aren't truly 'anchored' to.

2) Automatically resized collider on scroll bar foreground - Currently, the foreground sprite on a scroll bar is 'clipped', not resized. This means the foreground collider is actually the entire scroll bar. It'd be better if the collider matched the sprite. It can be done manually, but it seems like a more intuitive default behavior.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Small Feature Requests
« Reply #1 on: June 10, 2014, 02:21:52 AM »
#2 is a regression bug. I will fix that for the next update, thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Small Feature Requests
« Reply #2 on: June 10, 2014, 02:35:06 AM »
The fix for #2 is to replace NGUITools.UpdateWidgetCollider (line 327 of NGUITools.cs) with this:
  1.         static public void UpdateWidgetCollider (BoxCollider box, bool considerInactive)
  2.         {
  3.                 if (box != null)
  4.                 {
  5.                         GameObject go = box.gameObject;
  6.                         UIWidget w = go.GetComponent<UIWidget>();
  7.  
  8.                         if (w != null)
  9.                         {
  10.                                 Vector4 dr = w.drawRegion;
  11.  
  12.                                 if (dr.x != 0f || dr.y != 0f || dr.z != 1f || dr.w != 1f)
  13.                                 {
  14.                                         Vector4 region = w.drawingDimensions;
  15.                                         box.center = new Vector3((region.x + region.z) * 0.5f, (region.y + region.w) * 0.5f);
  16.                                         box.size = new Vector3(region.z - region.x, region.w - region.y);
  17.                                 }
  18.                                 else
  19.                                 {
  20.                                         Vector3[] corners = w.localCorners;
  21.                                         box.center = Vector3.Lerp(corners[0], corners[2], 0.5f);
  22.                                         box.size = corners[2] - corners[0];
  23.                                 }
  24.                         }
  25.                         else
  26.                         {
  27.                                 Bounds b = NGUIMath.CalculateRelativeWidgetBounds(go.transform, considerInactive);
  28.                                 box.center = b.center;
  29.                                 box.size = new Vector3(b.size.x, b.size.y, 0f);
  30.                         }
  31. #if UNITY_EDITOR
  32.                         NGUITools.SetDirty(box);
  33. #endif
  34.                 }
  35.         }

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Re: Small Feature Requests
« Reply #3 on: June 12, 2014, 02:50:08 PM »
One more small one.

It would be nice to be able to define the center for UICenterOnChild. I want to snap children into place, but I want the snap point somewhere other than the center of the panel clipping. I'm doing this in an unsafe way on a project by modifying how UICenterOnChild calculates the center of the relevant panel:

  1. Vector3[] corners = mScrollView.panel.localCorners;
  2. Vector3 panelCenter = (corners[2] + corners[0]) * 0.5f;
  3.  
  4. //Respect offset
  5. Vector3 offset = new Vector3(
  6.         mScrollView.panel.baseClipRegion.x,
  7.         mScrollView.panel.baseClipRegion.y);
  8. panelCenter = mScrollView.panel.cachedTransform.TransformPoint(panelCenter - offset);
  9.  

Obviously, this doesn't guarantee the 'center' will actually be inside the clipping at all, that would need a separate field and validation.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Small Feature Requests
« Reply #4 on: June 13, 2014, 03:58:36 AM »
Well then it wouldn't be CenterOnChild anymore, and would warrant a custom script.