Megadok 11 Report post Posted September 22, 2020 Buenas. ¿Es posible desactivar las opciones que nos salen al pulsar el botón derecho del mouse sobre algún objeto en la jerarquía? Ejemplo, quiero desactivar la opción de Copy o Delete. Gracias. Share this post Link to post Share on other sites
francoe1 536 Report post Posted September 22, 2020 Esta pregunta tiene una respuesta compleja, deberías editar el comportamiento del evento hierarchyWindowItemOnGUI y simular el menú con todos sus eventos. Se me ocurre algo como. using System.Collections; using UnityEditor; using UnityEngine; [InitializeOnLoad] public class CustomContextMenu { private static bool m_menuOpened = false; private static GameObject m_clickedOBject = null; private static Vector2 m_menuPosition; private static CustomContextMenu () { EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI; } private static void OnHierarchyGUI (int instanceID, Rect selectionRect) { //Detectar si se presiono el boton derecho del mouse. if (Event.current != null && selectionRect.Contains (Event.current.mousePosition) && Event.current.button == 1 && Event.current.type <= EventType.mouseUp) { GameObject clickedObject = EditorUtility.InstanceIDToObject (instanceID) as GameObject; if (clickedObject) { m_clickedOBject = clickedObject; m_menuPosition = Event.current.mousePosition; m_menuOpened = true; Event.current.Use (); } } //Simular el menu contextual, tambien se puede usar GenericMenu if (m_menuOpened) { if (GUI.Button (new Rect (m_menuPosition.x, m_menuPosition.y, 150, 20f), "Delete")) { m_menuOpened = false; GameObject.Destroy (m_clickedOBject); } } } } Share this post Link to post Share on other sites