UnitySerializedReferenceUI/Editor/DefaultUI/SerializeReferenceInspectorMiddleMouseMenu.cs

23 lines
697 B
C#
Raw Normal View History

#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
2022-12-28 14:06:42 +01:00
namespace Textus.SerializeReferenceUI.Editor
{
2022-12-28 14:06:42 +01:00
public static class SerializeReferenceInspectorMiddleMouseMenu
{
2022-12-28 14:06:42 +01:00
public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
2022-12-28 14:03:46 +01:00
{
2022-12-28 14:06:42 +01:00
Event e = Event.current;
if (e.type != EventType.MouseDown || !position.Contains(e.mousePosition) || e.button != 2)
{
return;
}
property.ShowContextMenuForManagedReference(filters);
2022-12-28 14:03:46 +01:00
}
}
}
#endif