简体   繁体   中英

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();
        }
    }
}

This part :

[MenuItem("GameObject/Make Pickup Item", false, 10)]
public static void CreateTextArea()
{
     GameObject go = new GameObject("Test");
}

Will add the "Make Pickup Item" at one place before the end at the bottom :

优先事项

The priority is set to 10 but if I want to add it to the very bottom under the Camera - how do I know what priority it should be?

Over here

You need priority > 11

Line 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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM