-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathBuildLayoutView.cs
More file actions
154 lines (131 loc) · 3.85 KB
/
BuildLayoutView.cs
File metadata and controls
154 lines (131 loc) · 3.85 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// Addressables Build Layout Explorer for Unity. Copyright (c) 2021 Peter Schraut (www.console-dev.de). See LICENSE.md
// https://github.com/pschraut/UnityAddressablesBuildLayoutExplorer
//
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using UnityEditor;
using UnityEngine;
namespace Oddworm.EditorFramework.BuildLayoutExplorer
{
public abstract class BuildLayoutView
{
/// <summary>
/// The titleContent is shown in toolbar View menu.
/// </summary>
public GUIContent titleContent
{
get;
set;
}
/// <summary>
/// Lets you control the menu item order in the View menu.
/// Use a negative value to hide an item from the View menu.
/// If two items are 100 units apart a seperator item is inserted inbetween.
/// </summary>
public int viewMenuOrder
{
get;
set;
}
/// <summary>
/// The window in which the view is rendered to.
/// </summary>
public BuildLayoutWindow window
{
get;
internal set;
}
/// <summary>
/// Gets whether the view is currently active.
/// </summary>
public bool isVisible
{
get;
private set;
}
/// <summary>
/// Gets the buildLayout.
/// </summary>
public RichBuildLayout buildLayout
{
get;
private set;
}
List<BuildLayoutView> m_Views = new List<BuildLayoutView>();
public BuildLayoutView()
{
viewMenuOrder = int.MaxValue - 1;
}
public virtual void Awake()
{
titleContent = new GUIContent(ObjectNames.NicifyVariableName(GetType().Name.Replace("View", "")));
}
public virtual void OnDestroy()
{
if (isVisible)
Hide();
m_Views = new List<BuildLayoutView>();
buildLayout = null;
window = null;
}
public virtual void Rebuild(RichBuildLayout buildLayout)
{
this.buildLayout = buildLayout;
foreach (var v in m_Views)
v.Rebuild(buildLayout);
window.Repaint();
}
public virtual void Show()
{
// Show any views that might have been added during OnShow()
foreach (var v in m_Views)
v.Show();
isVisible = true;
window.Repaint();
}
public virtual void Hide()
{
foreach (var v in m_Views)
v.Hide();
isVisible = false;
window.Repaint();
}
/// <summary>
/// Implement your own editor GUI here.
/// </summary>
public virtual void OnGUI()
{
}
/// <summary>
/// Implement the OnStatusbarGUI method to draw your own GUI in statusbar menu.
/// </summary>
public virtual void OnStatusbarGUI()
{
}
public virtual bool CanNavigateTo(object target)
{
return false;
}
public virtual void NavigateTo(object target)
{
}
/// <summary>
/// Returns an object that can be used to restore the current view.
/// </summary>
public abstract NavigationBookmark GetBookmark();
/// <summary>
/// Restores the view using the specified <paramref name="bookmark"/>.
/// </summary>
public abstract void SetBookmark(NavigationBookmark bookmark);
protected T CreateView<T>() where T : BuildLayoutView, new()
{
var view = new T();
view.window = window;
view.Awake();
m_Views.Add(view);
return view;
}
}
}