浏览代码

Create function updatePhysicalSize.

/main
Yuncong Zhang 5 年前
当前提交
834d11f5
共有 2 个文件被更改,包括 16 次插入14 次删除
  1. 27
      Runtime/editor/editor_window.cs
  2. 3
      Runtime/engine/UIWidgetsPanel.cs

27
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;
}
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(
this._lastWindowWidth * this._devicePixelRatio,
this._lastWindowHeight * this._devicePixelRatio);
this.updatePhysicalSize();
this.updateSafeArea();
D.assert(this._surface == null);
this._surface = this.createSurface();

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

3
Runtime/engine/UIWidgetsPanel.cs


protected override Vector2 queryWindowSize() {
var rect = this._uiWidgetsPanel.rectTransform.rect;
// 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;

正在加载...
取消
保存