https://www.cnblogs.com/zhaoqingqing/p/3315847.html
原文在上
//不在Inspector显示
[HideInInspector]
public int m_life = 3;//生命
public int m_wave = 1;//波数
public int m_point = 10;//点数
自定义菜单
[AddComponentMenu("Defend Homeland/PathTool")]
public class PathTool : ScriptableObject
{
static PathNode m_parent = null;
//新建一个菜单项【PathTool】,子菜单项(Set Parent)快捷键为 Ctrl + Q
[MenuItem("PathTool/Set Parent %q")]
static void SetParent ()
{
//如果没有选中任何物体,或选择物体数量大于1,则返回
if (!Selection.activeGameObject || Selection.GetTransforms (SelectionMode.Unfiltered).Length > 1)
return;
//如果选中,将选中的物体的tag设为pathnode
if (Selection.activeGameObject.tag.CompareTo ("pathnode") == 0) {
//设置父节点
m_parent = Selection.activeGameObject.GetComponent<PathNode> ();
}
}
//新建菜单项[PathTool/Set NextChild] ,快捷键为Ctrl+w
[MenuItem("PathTool/Set NextChild %w")]
static void SetNextChild ()
{
//如果没有选中任何物体,或选择的物体数量大于1,则返回
if (!Selection.activeGameObject || Selection.GetTransforms (SelectionMode.Unfiltered).Length > 1)
return;
if (Selection.activeGameObject.tag.CompareTo ("pathnode") == 0) {
//设置子节点
m_parent.SetNext (Selection.activeGameObject.GetComponent<PathNode> ());
m_parent = null;
}
}
}