using UnityEditor; using UnityEngine; namespace Thousandto.DIY { public class NGUICreateEx { [MenuItem("NGUI/Create/Button")] static void AddButton() { GameObject go = NGUIEditorTools.SelectedRoot(true); if (go != null) { var sprite = NGUISettings.AddSprite(go); var collider = sprite.gameObject.RequireComponent(); sprite.gameObject.RequireComponent(); sprite.autoResizeBoxCollider = true; collider.size = new Vector3(sprite.width, sprite.height); sprite.gameObject.name = "Button"; Selection.activeGameObject = sprite.gameObject; } else Debug.Log("You must select a game object first."); } } }