示例#1
0
 private static void SyncPositionCenter()
 {
     foreach (GameObject go in Selection.gameObjects)
     {
         Transform parent = go.transform;
         Bounds    bound  = NGUIMath.CalculateRelativeWidgetBounds(parent);
         float     dx     = bound.min.x + bound.size.x / 2;
         float     dy     = bound.max.y - bound.size.y / 2;
         foreach (Transform child in parent)
         {
             UIPivot.MovePosition(child, -dx, -dy, false);
         }
         UIPivot.MovePosition(parent, dx, dy, true);
     }
 }
示例#2
0
 public static void SyncPositionLeftTop()
 {
     if (Selection.activeGameObject != null)
     {
         foreach (GameObject go  in Selection.gameObjects)
         {
             Transform parent = go.transform;
             Bounds    bound  = NGUIMath.CalculateRelativeWidgetBounds(parent);
             float     dx     = bound.min.x;
             float     dy     = bound.max.y;
             foreach (Transform child in parent)
             {
                 UIPivot.MovePosition(child, -dx, -dy, false);
             }
             UIPivot.MovePosition(parent, dx, dy, true);
         }
     }
 }
 void OnEnable()
 {
     pivot = (UIPivot)target;
     pivot.Reposition();
 }