|
|
|
|
|
|
using UnityEditor; |
|
|
|
public abstract class UIWidgetsEditorWindow : EditorWindow { |
|
|
|
WindowAdapter _windowAdapter; |
|
|
|
public UIWidgetsEditorWindow() |
|
|
|
{ |
|
|
|
public UIWidgetsEditorWindow() { |
|
|
|
|
|
|
|
|
|
|
|
void OnEnable() { |
|
|
|
if (this._windowAdapter == null) { |
|
|
|
this._windowAdapter = new EditorWindowAdapter(this); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void OnGUI() { |
|
|
|
this._windowAdapter.OnGUI(); |
|
|
|
this._windowAdapter.OnGUI(Event.current); |
|
|
|
} |
|
|
|
|
|
|
|
void Update() { |
|
|
|
|
|
|
protected abstract Widget rootWidget(); |
|
|
|
} |
|
|
|
|
|
|
|
public class EditorWindowAdapter : WindowAdapter |
|
|
|
{ |
|
|
|
public class EditorWindowAdapter : WindowAdapter { |
|
|
|
public EditorWindowAdapter(EditorWindow editorWindow) |
|
|
|
{ |
|
|
|
public EditorWindowAdapter(EditorWindow editorWindow) { |
|
|
|
|
|
|
|
|
|
|
|
public override GUIContent titleContent |
|
|
|
{ |
|
|
|
public override GUIContent titleContent { |
|
|
|
|
|
|
|
protected override double queryDevicePixelRatio() |
|
|
|
{ |
|
|
|
|
|
|
|
protected override double queryDevicePixelRatio() { |
|
|
|
protected override Vector2 queryWindowSize() |
|
|
|
{ |
|
|
|
protected override Vector2 queryWindowSize() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public WidgetInspectorService widgetInspectorService |
|
|
|
{ |
|
|
|
public WidgetInspectorService widgetInspectorService { |
|
|
|
|
|
|
|
|
|
|
|
WidgetsBinding _binding; |
|
|
|
float _lastWindowWidth; |
|
|
|
float _lastWindowHeight; |
|
|
|
|
|
|
|
|
|
|
bool _regenerateLayerTree; |
|
|
|
Surface _surface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool alive |
|
|
|
{ |
|
|
|
|
|
|
|
public bool alive { |
|
|
|
get { return this._alive; } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
this._lastWindowWidth = size.x; |
|
|
|
this._lastWindowHeight =size.y; |
|
|
|
this._lastWindowHeight = size.y; |
|
|
|
this._physicalSize = new Size( |
|
|
|
this._lastWindowWidth * this._devicePixelRatio, |
|
|
|
this._lastWindowHeight * this._devicePixelRatio); |
|
|
|
|
|
|
public void OnDisable() { |
|
|
|
_windowAdapters.Remove(this); |
|
|
|
this._alive = false; |
|
|
|
|
|
|
|
|
|
|
|
this._rasterizer.teardown(); |
|
|
|
|
|
|
|
D.assert(this._surface != null); |
|
|
|
|
|
|
public WindowDisposable(WindowAdapter window) { |
|
|
|
this._window = window; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PostPointerEvent(List<PointerData> data) |
|
|
|
{ |
|
|
|
WithBinding(() => |
|
|
|
{ |
|
|
|
public void PostPointerEvent(List<PointerData> data) { |
|
|
|
WithBinding(() => { |
|
|
|
|
|
|
|
public void PostPointerEvent(PointerData data) |
|
|
|
{ |
|
|
|
PostPointerEvent(new List<PointerData>(){data}); |
|
|
|
|
|
|
|
public void PostPointerEvent(PointerData data) { |
|
|
|
PostPointerEvent(new List<PointerData>() { data }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void OnGUI() { |
|
|
|
|
|
|
|
public virtual void OnGUI(Event evt = null) { |
|
|
|
evt = evt??Event.current; |
|
|
|
using (this.getScope()) { |
|
|
|
bool dirty = false; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this._doOnGUI(); |
|
|
|
this._doOnGUI(evt); |
|
|
|
public virtual GUIContent titleContent |
|
|
|
{ |
|
|
|
public virtual GUIContent titleContent { |
|
|
|
|
|
|
|
|
|
|
|
protected virtual Surface createSurface() |
|
|
|
{ |
|
|
|
protected virtual Surface createSurface() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _beginFrame() { |
|
|
|
if (this.onBeginFrame != null) { |
|
|
|
this.onBeginFrame(new TimeSpan(Stopwatch.GetTimestamp()) - this._epoch); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void _doOnGUI() { |
|
|
|
var evt = Event.current; |
|
|
|
void _doOnGUI(Event evt) { |
|
|
|
|
|
|
|
if (evt.type == EventType.Repaint) { |
|
|
|
if (this._regenerateLayerTree) { |
|
|
|
|
|
|
this._rasterizer.drawLastLayerTree(); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Update() { |
|
|
|
Timer.update(); |
|
|
|
|
|
|
|
|
|
|
|
using (this.getScope()) { |
|
|
|
this._timerProvider.update(this.flushMicrotasks); |
|
|
|
this.flushMicrotasks(); |
|
|
|