Merged in c0ffeeartc/unity-ui-extensions (pull request #70)
Added undo to uGUITools.AnchorsToCorners, uGUITools.CornersToAnchorspull/413/head
commit
59b184d627
|
@ -9,9 +9,18 @@ namespace UnityEngine.UI.Extensions
|
||||||
[MenuItem("uGUI/Anchors to Corners %[")]
|
[MenuItem("uGUI/Anchors to Corners %[")]
|
||||||
static void AnchorsToCorners()
|
static void AnchorsToCorners()
|
||||||
{
|
{
|
||||||
|
if (Selection.transforms == null || Selection.transforms.Length == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Undo.IncrementCurrentGroup();
|
||||||
|
Undo.SetCurrentGroupName("AnchorsToCorners");
|
||||||
|
var undoGroup = Undo.GetCurrentGroup();
|
||||||
|
|
||||||
foreach (Transform transform in Selection.transforms)
|
foreach (Transform transform in Selection.transforms)
|
||||||
{
|
{
|
||||||
RectTransform t = transform as RectTransform;
|
RectTransform t = transform as RectTransform;
|
||||||
|
Undo.RecordObject( t, "AnchorsToCorners" );
|
||||||
RectTransform pt = Selection.activeTransform.parent as RectTransform;
|
RectTransform pt = Selection.activeTransform.parent as RectTransform;
|
||||||
|
|
||||||
if (t == null || pt == null) return;
|
if (t == null || pt == null) return;
|
||||||
|
@ -25,19 +34,30 @@ namespace UnityEngine.UI.Extensions
|
||||||
t.anchorMax = newAnchorsMax;
|
t.anchorMax = newAnchorsMax;
|
||||||
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
Undo.CollapseUndoOperations(undoGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("uGUI/Corners to Anchors %]")]
|
[MenuItem("uGUI/Corners to Anchors %]")]
|
||||||
static void CornersToAnchors()
|
static void CornersToAnchors()
|
||||||
{
|
{
|
||||||
|
if (Selection.transforms == null || Selection.transforms.Length == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Undo.IncrementCurrentGroup();
|
||||||
|
Undo.SetCurrentGroupName("CornersToAnchors");
|
||||||
|
var undoGroup = Undo.GetCurrentGroup();
|
||||||
|
|
||||||
foreach (Transform transform in Selection.transforms)
|
foreach (Transform transform in Selection.transforms)
|
||||||
{
|
{
|
||||||
RectTransform t = transform as RectTransform;
|
RectTransform t = transform as RectTransform;
|
||||||
|
Undo.RecordObject( t, "CornersToAnchors" );
|
||||||
|
|
||||||
if (t == null) return;
|
if (t == null) return;
|
||||||
|
|
||||||
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
Undo.CollapseUndoOperations(undoGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("uGUI/Mirror Horizontally Around Anchors %;")]
|
[MenuItem("uGUI/Mirror Horizontally Around Anchors %;")]
|
||||||
|
|
Loading…
Reference in New Issue