Last active
March 31, 2020 16:32
-
-
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.
This file contains hidden or 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 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Здесь не обязательно наследоваться от ScriptableObject , достаточно пустого статического класса.