Skip to content

Instantly share code, notes, and snippets.

@gekidoslair
Last active April 25, 2023 16:54
Show Gist options
  • Save gekidoslair/14d5ecd79ba6b4f6a3211d183d657785 to your computer and use it in GitHub Desktop.
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
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;
}
}
}
@gekidoslair
Copy link
Author

forgot to make the validation function...a validation function - updated ;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment