VR4Medical/ICI/Library/PackageCache/com.unity.collab-proxy@c854d1f7d97f/Editor/UI/DrawCopyableLabel.cs
2025-07-29 13:45:50 +03:00

34 lines
861 B
C#

using UnityEditor;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class DrawCopyableLabel
{
internal static void For(string label, GUIStyle style)
{
Rect rect = GUILayoutUtility.GetRect(
new GUIContent(label), style);
GUI.Label(rect, label, style);
if (Event.current.type != EventType.ContextClick)
return;
if (!rect.Contains(Event.current.mousePosition))
return;
GenericMenu menu = new GenericMenu();
menu.AddItem(
new GUIContent(PlasticLocalization.Name.Copy.GetString()),
false,
() => EditorGUIUtility.systemCopyBuffer = label);
menu.ShowAsContext();
Event.current.Use();
}
}
}