forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeLine.cs
More file actions
45 lines (37 loc) · 1.39 KB
/
Copy pathCodeLine.cs
File metadata and controls
45 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using Unity.CodeEditor;
using UnityEngine.UIElements;
namespace UnityEditor.UIElements.Debugger
{
class CodeLine : Label
{
string m_FileName;
int m_LineNumber;
public int hashCode { get; }
public CodeLine(string name, string fileName, int lineNumber, int hashCode) : base(name)
{
m_FileName = fileName;
m_LineNumber = lineNumber;
this.hashCode = hashCode;
}
protected override void ExecuteDefaultActionAtTarget(EventBase evt)
{
base.ExecuteDefaultActionAtTarget(evt);
if (elementPanel != null && elementPanel.contextualMenuManager != null)
{
elementPanel.contextualMenuManager.DisplayMenuIfEventMatches(evt, this);
}
if (evt.eventTypeId == ContextualMenuPopulateEvent.TypeId())
{
ContextualMenuPopulateEvent e = evt as ContextualMenuPopulateEvent;
e.menu.AppendAction("Go to callback registration point", GotoCode, DropdownMenuAction.AlwaysEnabled);
}
}
void GotoCode(DropdownMenuAction action)
{
CodeEditor.Editor.Current.OpenProject(m_FileName, m_LineNumber);
}
}
}