Last active
April 25, 2023 16:54
-
-
Save gekidoslair/14d5ecd79ba6b4f6a3211d183d657785 to your computer and use it in GitHub Desktop.
Simple Editor tool (place in an /Editor folder) to unparent gameobjects in the hierarchy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
namespace PixelWizards.Utilities | |
{ | |
public class UnparentGameObject | |
{ | |
[MenuItem("Edit/Unparent GameObject", false, 0)] | |
static void UnparentGO() | |
{ | |
var selection = Selection.activeTransform; | |
if (selection != null) | |
{ | |
selection.parent = null; | |
} | |
} | |
[MenuItem("Edit/Unparent GameObject", true, 0)] | |
static bool ValidateUnparentGO() | |
{ | |
// Return false if no transform is selected. | |
return Selection.activeTransform != null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
forgot to make the validation function...a validation function - updated ;}