Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: davidgutierrezpalma on July 03, 2013, 11:17:29 AM

Title: Feature Request: CalculateRelativeWidgetBounds and inactive GameObjects
Post by: davidgutierrezpalma on July 03, 2013, 11:17:29 AM
@ArenMook

I have found a situation where I would like to find out the bounds of a Prefab or an inactive object, but the current NGUIMath.CalculateRelativeWidgetBounds() method only takes into account active objects. As I explained in another thread ( http://www.tasharen.com/forum/index.php?topic=4758.0 (http://www.tasharen.com/forum/index.php?topic=4758.0) ), although this is a change that can be done very easily, I'd rather you included it in the official distribution than applying my own patches with every new release...


This would be my suggested implementation (to avoid breaking old code):
  1. static public Bounds CalculateRelativeWidgetBounds (Transform root, Transform child){
  2.         CalculateRelativeWidgetBounds(root, child, false);
  3. }
  4.  
  5. static public Bounds CalculateRelativeWidgetBounds (Transform root, Transform child, bool includeInactive){
  6.         UIWidget[] widgets = child.GetComponentsInChildren<UIWidget>(includeInactive) as UIWidget[];
  7.  
  8.         // The rest of the code of the function
  9. }
  10.  
I have only modified this function because it was the only function I needed, but maybe a similar "pattern" could be applied to other parts of the codebase...


By the way, I have seen that you didn't reply my last post in the other thread, should I assume that my feature request got buried by another threads or was a polite way of telling me that you aren't interested in that feature and I should implement it myself?  ::)

I wouldn't have any problem with that, it's only that I'm a lazy and I hate applying my custom patches to a product that is updated so frequently. ;)

//------------------------------------------------------//

EDIT:
CalculateAbsoluteWidgetBounds() would be another candidate for the same "pattern".
Title: Re: Feature Request: CalculateRelativeWidgetBounds and inactive GameObjects
Post by: ArenMook on July 03, 2013, 03:37:16 PM
I suggest you create your own tools class and add that function there instead of modifying NGUIMath / NGUITools functions.