Last active
March 3, 2020 21:26
-
-
Save jackyyang09/f6cf3acb5c1aae99b24cb88a37fe17e7 to your computer and use it in GitHub Desktop.
A somewhat extended version of a gist uploaded by user gekidoslair that adds two new lines of code. New code selects the new object created and adds the creation of the object to the undo stack
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; | |
using UnityEngine; | |
namespace MWU.Shared.Utilities | |
{ | |
/// <summary> | |
/// Adds 'Create Empty at Root' shortcut for the GameObject / right-click context menu to create an empty gameobject at 0,0,0 | |
/// Original can be found here: https://gist.github.com/gekidoslair/359535dd108ce3dfac6b564ad37e42fe | |
/// </summary> | |
public class CreateEmptyAtRoot : MonoBehaviour | |
{ | |
[MenuItem("GameObject/Create Empty at Root", false, 0)] | |
public static void Create() | |
{ | |
var go = new GameObject(); | |
go.name = "GameObject"; | |
go.transform.position = Vector3.zero; | |
go.transform.rotation = Quaternion.identity; | |
Undo.RegisterCreatedObjectUndo(go, "Added new gameobject at root"); | |
Selection.activeTransform = go.transform; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment