Skip to content

Instantly share code, notes, and snippets.

@attilam
Last active March 31, 2020 16:32
Show Gist options
  • Save attilam/5648330 to your computer and use it in GitHub Desktop.
Save attilam/5648330 to your computer and use it in GitHub Desktop.
Tiny Unity3D editor script to create a new GameObject at selection. Invoke with Alt+N.
using UnityEngine;
using UnityEditor;
public class CreateEmptyAtSelection : ScriptableObject {
[MenuItem("GameObject/Create Empty at Selection &n")]
static void CreateEmpty() {
GameObject go = new GameObject();
if (Selection.activeTransform != null) {
go.transform.parent = Selection.activeTransform;
go.transform.localPosition = Vector3.zero;
go.transform.localRotation = Quaternion.identity;
go.transform.localScale = Vector3.one;
}
Selection.activeGameObject = go;
}
}
@MichaelPizik
Copy link

Здесь не обязательно наследоваться от ScriptableObject , достаточно пустого статического класса.

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