浏览代码

Merge pull request #107 from UnityTech/yczhang

Yczhang
/main
GitHub 6 年前
当前提交
1e1ab360
共有 4 个文件被更改,包括 67 次插入7 次删除
  1. 5
      README-ZH.md
  2. 5
      README.md
  3. 22
      Runtime/editor/editor_window.cs
  4. 42
      Runtime/ui/window.cs

5
README-ZH.md


当一个Unity项目运行在Android设备上时,状态栏是默认隐藏且无法在编辑内进行调整的。
如果您希望在您的UIWidgets App中显示状态栏,您可以使用这个[解决方案](https://github.com/Over17/UnityShowAndroidStatusBar)。我们将尽快推出我们自己的解决方案,并保证届时开发者可以进行无缝切换。
#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低为15,在界面变动时将帧率提高至60。
如果您需要修改帧率升高或降低时的行为,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为您自己的函数。
## 调试UIWidgets应用程序

5
README.md


compatible to UIWidgets, therefore can be used as a good option before we release our
full support solution on this issue.
#### Automatically Adjust Frame Rate
To build an App that is able to adjust the frame rate automatically, please open Project Settings, and in the Quality tab, set the "V Sync Count" option of the target platform to "Don't Sync".
The default logic is to set the frame rate to 15 when the screen is static, and change the frame rate to 60 whenever the screen changes.
If you would like to modify the behavior of speeding up or cooling down the frame rate, please set `Window.onFrameRateSpeedUp` and/or `Window.onFrameRateCoolDown` to your own functions.
## Debug UIWidgets Application

22
Runtime/editor/editor_window.cs


protected override float queryDevicePixelRatio() {
return EditorGUIUtility.pixelsPerPoint;
}
return Window.defaultAntiAliasing;
return defaultAntiAliasing;
}
protected override Vector2 queryWindowSize() {

public void OnEnable() {
this._devicePixelRatio = this.queryDevicePixelRatio();
this._antiAliasing = this.queryAntiAliasing();
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;

if (this.displayMetricsChanged()) {
this._devicePixelRatio = this.queryDevicePixelRatio();
this._antiAliasing = this.queryAntiAliasing();
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;

this.flushMicrotasks();
}
}
static readonly TimeSpan _coolDownDelay = new TimeSpan(0, 0, 0, 0, 200);
static Timer frameCoolDownTimer;
onFrameRateSpeedUp();
frameCoolDownTimer?.cancel();
frameCoolDownTimer = instance.run(
_coolDownDelay,
() => {
onFrameRateCoolDown();
frameCoolDownTimer = null;
});
}
public override void render(Scene scene) {

42
Runtime/ui/window.cs


using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public delegate void VoidCallback();

}
protected float _devicePixelRatio = 1.0f;
public int antiAliasing {
get { return this._antiAliasing; }
}

public float getFPS() {
return 1.0f / this.fpsDeltaTime;
}
public const int defaultMaxTargetFrameRate = 60;
public const int defaultMinTargetFrameRate = 15;
static Action _onFrameRateSpeedUp = defaultFrameRateSpeedUp;
public static Action onFrameRateSpeedUp {
get { return _onFrameRateSpeedUp; }
set {
if (value == null) {
_onFrameRateSpeedUp = defaultFrameRateSpeedUp;
}
else {
_onFrameRateSpeedUp = value;
}
}
}
static void defaultFrameRateSpeedUp() {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
static Action _onFrameRateCoolDown = defaultFrameRateCoolDown;
public static Action onFrameRateCoolDown {
get { return _onFrameRateCoolDown; }
set {
if (value == null) {
_onFrameRateCoolDown = defaultFrameRateCoolDown;
}
else {
_onFrameRateCoolDown = value;
}
}
}
static void defaultFrameRateCoolDown() {
Application.targetFrameRate = defaultMinTargetFrameRate;
}
}
}
正在加载...
取消
保存