Last active
December 21, 2015 05:49
-
-
Save yumehachi/6259460 to your computer and use it in GitHub Desktop.
選択中のアイテムの中に空のオブジェクトを生成するUnity Editorスクリプト
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 UnityEngine; | |
using UnityEditor; | |
/// <summary> | |
/// 選択中のアイテムの中に空のオブジェクトを生成 | |
/// </summary> | |
/// <author> | |
/// Create by yumehachi on 2013/08/18 | |
/// </author> | |
public class CreateEmpty | |
{ | |
[MenuItem ("GameObject/Create Other/Create Empty %.")] | |
static void CreateEmptyGameObject () | |
{ | |
Transform[] selection = Selection.GetTransforms (SelectionMode.DeepAssets); | |
GameObject newParent = new GameObject ("Empty"); | |
foreach (Transform t in selection) { | |
newParent.transform.parent = t.transform; | |
newParent.layer = t.gameObject.layer; | |
} | |
newParent.transform.localPosition = Vector3.zero; | |
newParent.transform.localScale = Vector3.one; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment