-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathGraphViewEditorWindow.cs
More file actions
74 lines (61 loc) · 2.99 KB
/
GraphViewEditorWindow.cs
File metadata and controls
74 lines (61 loc) · 2.99 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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace UnityEditor.Experimental.GraphView
{
public abstract class GraphViewEditorWindow : EditorWindow
{
public virtual IEnumerable<GraphView> graphViews { get; }
public override IEnumerable<Type> GetExtraPaneTypes()
{
return Assembly
.GetAssembly(typeof(GraphViewToolWindow))
.GetTypes()
.Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(GraphViewToolWindow)));
}
public static List<EditorWindow> ShowGraphViewWindowWithTools<T>() where T : GraphViewEditorWindow
{
const float width = 1200;
const float height = 800;
const float toolsWidth = 200;
var mainSplitView = CreateInstance<SplitView>();
var sideSplitView = CreateInstance<SplitView>();
sideSplitView.vertical = true;
sideSplitView.position = new Rect(0, 0, toolsWidth, height);
var dockArea = CreateInstance<DockArea>();
dockArea.position = new Rect(0, 0, toolsWidth, height - toolsWidth);
var blackboardWindow = CreateInstance<GraphViewBlackboardWindow>();
dockArea.AddTab(blackboardWindow);
sideSplitView.AddChild(dockArea);
dockArea = CreateInstance<DockArea>();
dockArea.position = new Rect(0, 0, toolsWidth, toolsWidth);
var minimapWindow = CreateInstance<GraphViewMinimapWindow>();
dockArea.AddTab(minimapWindow);
sideSplitView.AddChild(dockArea);
mainSplitView.AddChild(sideSplitView);
dockArea = CreateInstance<DockArea>();
var graphViewWindow = CreateInstance<T>();
dockArea.AddTab(graphViewWindow);
dockArea.position = new Rect(0, 0, width - toolsWidth, height);
mainSplitView.AddChild(dockArea);
var graphView = graphViewWindow.graphViews.FirstOrDefault();
if (graphView != null)
{
blackboardWindow.SelectGraphViewFromWindow(graphViewWindow, graphView);
minimapWindow.SelectGraphViewFromWindow(graphViewWindow, graphView);
}
var containerWindow = CreateInstance<ContainerWindow>();
containerWindow.m_DontSaveToLayout = false;
containerWindow.position = new Rect(100, 100, width, height);
containerWindow.rootView = mainSplitView;
containerWindow.rootView.position = new Rect(0, 0, mainSplitView.position.width, mainSplitView.position.height);
containerWindow.Show(ShowMode.NormalWindow, false, true, setFocus: true);
return new List<EditorWindow> { graphViewWindow, blackboardWindow, minimapWindow };
}
}
}