Skip to content

Instantly share code, notes, and snippets.

@yumehachi
Last active December 21, 2015 05:49
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 yumehachi/6259460 to your computer and use it in GitHub Desktop.
Save yumehachi/6259460 to your computer and use it in GitHub Desktop.
選択中のアイテムの中に空のオブジェクトを生成するUnity Editorスクリプト
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