给Unity编辑器添加内容: MenuItem
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class HAHAHA : MonoBehaviour {
[MenuItem("GameObject/MyCategory/Custom Game Object", false, 0)]
static void CreateCustomGameObject(MenuCommand menuCommand)
{
menuCommand.context = Selection.activeObject;
GameObject go = new GameObject("Custom Game Object");
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(go, "Create " + go);
Selection.activeObject = go;
}
}