forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphViewMinimapWindow.cs
More file actions
78 lines (64 loc) · 2.18 KB
/
Copy pathGraphViewMinimapWindow.cs
File metadata and controls
78 lines (64 loc) · 2.18 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.Experimental.GraphView
{
[EditorWindowTitle(title = k_ToolName)]
public class GraphViewMinimapWindow : GraphViewToolWindow
{
MiniMap m_MiniMap;
Label m_ZoomLabel;
const string k_ToolName = "MiniMap";
protected override string ToolName => k_ToolName;
new void OnEnable()
{
base.OnEnable();
var root = rootVisualElement;
m_MiniMap = new MiniMap();
m_MiniMap.windowed = true;
m_MiniMap.zoomFactorTextChanged += ZoomFactorTextChanged;
root.Add(m_MiniMap);
OnGraphViewChanged();
m_ZoomLabel = new Label();
m_ZoomLabel.style.width = 35;
m_ZoomLabel.style.unityTextAlign = TextAnchor.MiddleRight;
m_ToolbarContainer.Add(m_ZoomLabel);
}
void OnDestroy()
{
if (m_SelectedGraphView != null)
m_SelectedGraphView.redrawn -= GraphViewRedrawn;
}
protected override void OnGraphViewChanging()
{
if (m_SelectedGraphView != null)
m_SelectedGraphView.redrawn -= GraphViewRedrawn;
}
protected override void OnGraphViewChanged()
{
if (m_SelectedGraphView != null)
m_SelectedGraphView.redrawn += GraphViewRedrawn;
else
ZoomFactorTextChanged("");
if (m_MiniMap == null) // Probably called from base.OnEnable(). We're not ready just yet.
return;
m_MiniMap.graphView = m_SelectedGraphView;
m_MiniMap.MarkDirtyRepaint();
}
void ZoomFactorTextChanged(string text)
{
if (m_ZoomLabel != null)
m_ZoomLabel.text = text;
}
void GraphViewRedrawn()
{
m_MiniMap.MarkDirtyRepaint();
}
protected override bool IsGraphViewSupported(GraphView gv)
{
return true;
}
}
}