Skip to content

Instantly share code, notes, and snippets.

@kirillrybin
Created September 27, 2013 22:41
Show Gist options
  • Save kirillrybin/6736245 to your computer and use it in GitHub Desktop.
Save kirillrybin/6736245 to your computer and use it in GitHub Desktop.
Create nested Child Gameobject in selected transform.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class Child : MonoBehaviour {
[MenuItem ("GameObject/Create Child #&n")]
static void DoSomething () {
if (Selection.activeTransform){
var go = new GameObject();
go.name = "Child";
go.transform.parent = Selection.activeTransform;
go.transform.localPosition = Vector3.zero;
go.transform.localRotation = Quaternion.identity;
go.transform.localScale = new Vector3(1,1,1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment