Skip to content

Instantly share code, notes, and snippets.

@dbuck
Created July 16, 2013 14:15
Show Gist options
  • Select an option

  • Save dbuck/6009100 to your computer and use it in GitHub Desktop.

Select an option

Save dbuck/6009100 to your computer and use it in GitHub Desktop.
Editor code snip to replace the CreateEmpty gameobject function with one that will always show up as the child of the currently selected game object.
[MenuItem("GameObject/Create Empty %#n", priority = -1)]
static void menu_GameObject_CreateEmpty()
{
//Debug.Log("menu_GameObject_CreateEmpty");
Undo.RegisterSceneUndo("Create Empty");
GameObject go = new GameObject("GameObject");
go.transform.parent = Selection.activeTransform;
go.transform.localPosition = Vector3.zero;
go.transform.localRotation = Quaternion.identity;
go.transform.localScale = Vector3.one;
Selection.activeObject = go;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment