Skip to content

Instantly share code, notes, and snippets.

@hk1ll3r
Created October 20, 2020 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hk1ll3r/77ecc299ce305051b26139960fdb9c25 to your computer and use it in GitHub Desktop.
Save hk1ll3r/77ecc299ce305051b26139960fdb9c25 to your computer and use it in GitHub Desktop.
[MenuItem("GameObject/My Objects/Target", priority = 10)]
public static void CreateNewTarget(MenuCommand menuCommand) {
var go = new GameObject("New Target");
go.AddComponent<TargetController>();
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment