浏览代码

fix blank on first frame

/main
fzhangtj 6 年前
当前提交
7f02e62b
共有 2 个文件被更改,包括 47 次插入69 次删除
  1. 92
      Runtime/editor/editor_window.cs
  2. 24
      Runtime/engine/WidgetCanvas.cs

92
Runtime/editor/editor_window.cs


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();

24
Runtime/engine/WidgetCanvas.cs


base.scheduleFrame(regenerateLayerTree);
_needsPaint = true;
}
public override void OnGUI()
public override void OnGUI(Event evt)
if (Event.current.type == EventType.Repaint)
if (evt.type == EventType.Repaint)
base.OnGUI();
base.OnGUI(evt);
}
protected override Surface createSurface()

_windowAdapter.OnEnable();
var root = new WidgetsApp(null, getWidget(), _windowAdapter);
_windowAdapter.attachRootWidget(root);
_lastMouseMove = Input.mousePosition;
}

{
this._windowAdapter.Update();
}
this._windowAdapter.OnGUI(new Event() {type=EventType.Repaint});
private void OnGUI()
private void OnGUI()
if (Event.current.type == EventType.Repaint)
{
this._windowAdapter.OnGUI();
}
if (this._windowAdapter != null)
{
this._windowAdapter.OnGUI();
}
this._windowAdapter.OnGUI(Event.current);
}
}

正在加载...
取消
保存