![](/img/trans.png)
[英]How can I add a option to a GameObject in the Hierarchy context menu?
[英]How can I add a context menu option to a gameobject in the hierarchy to be at the bottom?
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(PickupObjects))]
public class PickupObjectsEditor : Editor
{
[MenuItem("GameObject/Make Pickup Item", false, 10)]
public static void CreateTextArea()
{
GameObject go = new GameObject("Test");
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
PickupObjects pickupobjects = (PickupObjects)target;
if (GUILayout.Button("Generate Pickup Objects"))
{
pickupobjects.GeneratePickupObjects();
}
}
}
這部分 :
[MenuItem("GameObject/Make Pickup Item", false, 10)]
public static void CreateTextArea()
{
GameObject go = new GameObject("Test");
}
將在底部末尾的一處添加“Make Pickup Item”:
優先級設置為 10 但如果我想將它添加到相機下方的最底部 - 我怎么知道它應該是什么優先級?
您需要priority
> 11
第 280 行:
[MenuItem("GameObject/Camera", priority = 11)]
static void CreateCamera(MenuCommand menuCommand)
{
var parent = menuCommand.context as GameObject;
Place(ObjectFactory.CreateGameObject("Camera", typeof(Camera), typeof(AudioListener)), parent);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.