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); }
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); }
public static AABBox CalculateAbsoluteWidgetBounds(Transform trans) { using (WidgetList list = GetWidgetsInChildren(trans)) { if (list.empty) { return(new AABBox()); } AABBox box = new AABBox(); bool flag = true; foreach (UIWidget widget in list) { Vector2 vector; Vector2 vector2; AABBox box2; Vector3 vector3; Vector3 vector4; widget.GetPivotOffsetAndRelativeSize(out vector2, out vector); vector3.x = (vector2.x + 0.5f) * vector.x; vector3.y = (vector2.y - 0.5f) * vector.y; vector4.x = vector3.x + (vector.x * 0.5f); vector4.y = vector3.y + (vector.y * 0.5f); vector3.x -= vector.x * 0.5f; vector3.y -= vector.y * 0.5f; vector3.z = 0f; vector4.z = 0f; AABBox box3 = new AABBox(ref vector3, ref vector4); Matrix4x4 localToWorldMatrix = widget.cachedTransform.localToWorldMatrix; box3.TransformedAABB3x4(ref localToWorldMatrix, out box2); if (flag) { box = box2; flag = false; } else { box.Encapsulate(ref box2); } } if (flag) { return(new AABBox(trans.position)); } return(box); } }
public static AABBox CalculateRelativeWidgetBounds(Transform root, Transform child) { using (WidgetList list = GetWidgetsInChildren(child)) { if (list.empty) { return(new AABBox()); } bool flag = true; AABBox box = new AABBox(); Matrix4x4 worldToLocalMatrix = root.worldToLocalMatrix; foreach (UIWidget widget in list) { Vector2 vector; Vector2 vector2; Vector3 vector3; Vector3 vector4; AABBox box3; widget.GetPivotOffsetAndRelativeSize(out vector2, out vector); vector3.x = (vector2.x + 0.5f) * vector.x; vector3.y = (vector2.x - 0.5f) * vector.y; vector3.z = 0f; vector4.x = vector3.x + (vector.x * 0.5f); vector4.y = vector3.y + (vector.y * 0.5f); vector4.z = 0f; vector3.x -= vector.x * 0.5f; vector3.y -= vector.y * 0.5f; Matrix4x4 t = worldToLocalMatrix * widget.cachedTransform.localToWorldMatrix; new AABBox(ref vector3, ref vector4).TransformedAABB3x4(ref t, out box3); if (flag) { box = box3; flag = false; } else { box.Encapsulate(ref box3); } } return(box); } }