Example #1
0
    private static void FillWidgetListWithChildren(Transform trans, ref NGUIMath.WidgetList list, ref bool madeList)
    {
        UIWidget component = trans.GetComponent <UIWidget>();

        if (component)
        {
            if (!madeList)
            {
                list     = NGUIMath.WidgetList.Generate();
                madeList = true;
            }
            list.Add(component);
        }
        int num = trans.childCount;

        while (true)
        {
            int num1 = num;
            num = num1 - 1;
            if (num1 <= 0)
            {
                break;
            }
            NGUIMath.FillWidgetListWithChildren(trans.GetChild(num), ref list, ref madeList);
        }
    }
Example #2
0
 public static NGUIMath.WidgetList Generate()
 {
     if (NGUIMath.WidgetList.tempWidgetListsSize == 0)
     {
         return(new NGUIMath.WidgetList(false));
     }
     NGUIMath.WidgetList widgetList = NGUIMath.WidgetList.tempWidgetLists.Dequeue();
     widgetList.disposed = false;
     NGUIMath.WidgetList.tempWidgetListsSize = NGUIMath.WidgetList.tempWidgetListsSize - 1;
     return(widgetList);
 }
Example #3
0
 public static NGUIMath.WidgetList Generate()
 {
     if (tempWidgetListsSize == 0)
     {
         return(new NGUIMath.WidgetList(false));
     }
     NGUIMath.WidgetList list = tempWidgetLists.Dequeue();
     list.disposed = false;
     tempWidgetListsSize--;
     return(list);
 }
Example #4
0
 private static NGUIMath.WidgetList GetWidgetsInChildren(Transform trans)
 {
     if (trans)
     {
         bool flag = false;
         NGUIMath.WidgetList widgetList = null;
         NGUIMath.FillWidgetListWithChildren(trans, ref widgetList, ref flag);
         if (flag)
         {
             return(widgetList);
         }
     }
     return(NGUIMath.WidgetList.Empty);
 }
Example #5
0
    public static AABBox CalculateRelativeWidgetBounds(Transform root, Transform child)
    {
        Vector2 vector2;
        Vector2 vector21;
        Vector3 vector3  = new Vector3();
        Vector3 vector31 = new Vector3();
        AABBox  aABBox;
        AABBox  aABBox1;

        using (NGUIMath.WidgetList widgetsInChildren = NGUIMath.GetWidgetsInChildren(child))
        {
            if (!widgetsInChildren.empty)
            {
                bool      flag      = true;
                AABBox    aABBox2   = new AABBox();
                Matrix4x4 matrix4x4 = root.worldToLocalMatrix;
                foreach (UIWidget widgetsInChild in widgetsInChildren)
                {
                    widgetsInChild.GetPivotOffsetAndRelativeSize(out vector21, out vector2);
                    vector3.x  = (vector21.x + 0.5f) * vector2.x;
                    vector3.y  = (vector21.x - 0.5f) * vector2.y;
                    vector3.z  = 0f;
                    vector31.x = vector3.x + vector2.x * 0.5f;
                    vector31.y = vector3.y + vector2.y * 0.5f;
                    vector31.z = 0f;
                    vector3.x  = vector3.x - vector2.x * 0.5f;
                    vector3.y  = vector3.y - vector2.y * 0.5f;
                    Matrix4x4 matrix4x41 = matrix4x4 * widgetsInChild.cachedTransform.localToWorldMatrix;
                    AABBox    aABBox3    = new AABBox(ref vector3, ref vector31);
                    aABBox3.TransformedAABB3x4(ref matrix4x41, out aABBox);
                    if (!flag)
                    {
                        aABBox2.Encapsulate(ref aABBox);
                    }
                    else
                    {
                        aABBox2 = aABBox;
                        flag    = false;
                    }
                }
                aABBox1 = aABBox2;
            }
            else
            {
                aABBox1 = new AABBox();
            }
        }
        return(aABBox1);
    }
Example #6
0
    public static AABBox CalculateAbsoluteWidgetBounds(Transform trans)
    {
        Vector2 vector2;
        Vector2 vector21;
        AABBox  aABBox;
        Vector3 vector3  = new Vector3();
        Vector3 vector31 = new Vector3();
        AABBox  aABBox1;

        using (NGUIMath.WidgetList widgetsInChildren = NGUIMath.GetWidgetsInChildren(trans))
        {
            if (!widgetsInChildren.empty)
            {
                AABBox aABBox2 = new AABBox();
                bool   flag    = true;
                foreach (UIWidget widgetsInChild in widgetsInChildren)
                {
                    widgetsInChild.GetPivotOffsetAndRelativeSize(out vector21, out vector2);
                    vector3.x  = (vector21.x + 0.5f) * vector2.x;
                    vector3.y  = (vector21.y - 0.5f) * vector2.y;
                    vector31.x = vector3.x + vector2.x * 0.5f;
                    vector31.y = vector3.y + vector2.y * 0.5f;
                    vector3.x  = vector3.x - vector2.x * 0.5f;
                    vector3.y  = vector3.y - vector2.y * 0.5f;
                    vector3.z  = 0f;
                    vector31.z = 0f;
                    AABBox    aABBox3   = new AABBox(ref vector3, ref vector31);
                    Matrix4x4 matrix4x4 = widgetsInChild.cachedTransform.localToWorldMatrix;
                    aABBox3.TransformedAABB3x4(ref matrix4x4, out aABBox);
                    if (!flag)
                    {
                        aABBox2.Encapsulate(ref aABBox);
                    }
                    else
                    {
                        aABBox2 = aABBox;
                        flag    = false;
                    }
                }
                aABBox1 = (!flag ? aABBox2 : new AABBox(trans.position));
            }
            else
            {
                aABBox1 = new AABBox();
            }
        }
        return(aABBox1);
    }