浏览代码

Merge pull request #240 from UnityTech/fix_prefab

Fix issue introduced by moving queryWindowSize to update.
/main
GitHub 5 年前
当前提交
43462e12
共有 2 个文件被更改,包括 40 次插入31 次删除
  1. 23
      Runtime/editor/editor_window.cs
  2. 48
      Runtime/engine/UIWidgetsPanel.cs

23
Runtime/editor/editor_window.cs


protected float deltaTime;
protected float unscaledDeltaTime;
void updatePhysicalSize() {
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(
this._lastWindowWidth * this._devicePixelRatio,
this._lastWindowHeight * this._devicePixelRatio);
}
protected virtual void updateDeltaTime() {
this.deltaTime = Time.unscaledDeltaTime;

public void onViewMetricsChanged() {
this._viewMetricsChanged = true;
}
this.updatePhysicalSize();
this.updateSafeArea();
D.assert(this._surface == null);
this._surface = this.createSurface();

}
public void Update() {
if (this._physicalSize == null) {
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(
this._lastWindowWidth * this._devicePixelRatio,
this._lastWindowHeight * this._devicePixelRatio);
if (this._physicalSize == null || this._physicalSize.isEmpty) {
this.updatePhysicalSize();
}
this.updateDeltaTime();

48
Runtime/engine/UIWidgetsPanel.cs


protected override float queryDevicePixelRatio() {
return this._uiWidgetsPanel.devicePixelRatio;
}
protected override int queryAntiAliasing() {
return this._uiWidgetsPanel.antiAliasing;
}

var size = new Vector2(rect.width, rect.height) *
this._uiWidgetsPanel.canvas.scaleFactor / this._uiWidgetsPanel.devicePixelRatio;
size.x = Mathf.Round(size.x);
size.y = Mathf.Round(size.y);
return size;
// Here we use ReferenceEquals instead of "==" due to
// https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
// In short, "==" is overloaded for UnityEngine.Object and will bring performance issues
if (!ReferenceEquals(this._uiWidgetsPanel.canvas, null)) {
var size = new Vector2(rect.width, rect.height) *
this._uiWidgetsPanel.canvas.scaleFactor / this._uiWidgetsPanel.devicePixelRatio;
size.x = Mathf.Round(size.x);
size.y = Mathf.Round(size.y);
return size;
}
return new Vector2(0, 0);
}
public Offset windowPosToScreenPos(Offset windowPos) {

this._displayMetrics = DisplayMetricsProvider.provider();
this._displayMetrics.OnEnable();
this._enteredPointers.Clear();
if (_repaintEvent == null) {

: this._displayMetrics.devicePixelRatio;
}
}
get {
return this.antiAliasingOverride >= 0 ? this.antiAliasingOverride : QualitySettings.antiAliasing;
}
get { return this.antiAliasingOverride >= 0 ? this.antiAliasingOverride : QualitySettings.antiAliasing; }
}
public WindowPadding viewPadding {

get { return this._displayMetrics.viewInsets; }
}
protected override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;
base.OnDisable();
protected override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;
base.OnDisable();
public void recreateWidget() {
Widget root;
using (this._windowAdapter.getScope()) {

protected virtual void Update() {
this._displayMetrics.Update();
UIWidgetsMessageManager.ensureUIWidgetsMessageManagerIfNeeded();
this._windowAdapter.withBinding(() => {
WidgetsBinding.instance.handlePopRoute();
});
this._windowAdapter.withBinding(() => { WidgetsBinding.instance.handlePopRoute(); });
}
#endif

break;
}
}
return InputUtils.getMouseButtonKey(defaultKey);
}

正在加载...
取消
保存