Skip to content

Commit beef940

Browse files
authored
Create UnparentMe.cs
1 parent e6b3657 commit beef940

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// unparents selected gameobject in hierarchy (by moving to grandparents if available)
2+
3+
using UnityEditor;
4+
5+
namespace UnityLibrary
6+
{
7+
public class UnparentMe
8+
{
9+
// https://docs.unity3d.com/ScriptReference/MenuItem.html
10+
// shift U shortcut key
11+
[MenuItem("GameObject/Unparent #u")]
12+
static void UnParent()
13+
{
14+
// TODO: add undo
15+
if (Selection.activeGameObject != null && Selection.activeGameObject.transform.parent != null)
16+
{
17+
Selection.activeGameObject.transform.parent = Selection.activeGameObject.transform.parent.parent;
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)