浏览代码

Update.

/main
Yuncong Zhang 6 年前
当前提交
cbaa6ee2
共有 4 个文件被更改,包括 51 次插入27 次删除
  1. 2
      README-ZH.md
  2. 2
      README.md
  3. 16
      Runtime/editor/editor_window.cs
  4. 58
      Runtime/ui/window.cs

2
README-ZH.md


#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低为15,在界面变动时将帧率提高至60。
如果您需要修改此逻辑,请将`Window.speedUpFrameRate`和/或`Window.coolDownFrameRate`设置为您自己的函数。
如果您需要修改帧率升高或降低时的行为,请将`Window.speedUpFrameRate`和/或`Window.coolDownFrameRate`设置为您自己的函数。
## 调试UIWidgets应用程序

2
README.md


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 this logic, please set `Window.speedUpFrameRate` and/or `Window.coolDownFrameRate` to your own functions.
If you would like to modify the behavior of speeding up or cooling down the frame rate, please set `Window.speedUpFrameRate` and/or `Window.coolDownFrameRate` to your own functions.
## Debug UIWidgets Application

16
Runtime/editor/editor_window.cs


this._binding.renderView?.visitChildren(visitor);
}
}
static Timer scheduleFrameTimer;
static void doSpeedUp() {
onFrameRateSpeedUp();
}
static void doCoolDown() {
scheduleFrameTimer?.cancel();
scheduleFrameTimer = instance.run(
new TimeSpan(0, 0, 0, 0, 200),
() => {
onFrameRateCoolDown();
scheduleFrameTimer = null;
});
}
}
}

58
Runtime/ui/window.cs


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

public float getFPS() {
return 1.0f / this.fpsDeltaTime;
}
public static Action speedUpFrameRate;
public static Action coolDownFrameRate;
static Timer scheduleFrameTimer;
public static void doSpeedUp() {
if (speedUpFrameRate == null) {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
else {
speedUpFrameRate();
static Action _onFrameRateSpeedUp = () => { defaultFrateRateSpeedUp(); };
public static Action onFrameRateSpeedUp {
get { return _onFrameRateSpeedUp; }
set {
if (value == null) {
_onFrameRateSpeedUp = () => { defaultFrateRateSpeedUp(); };
}
else {
_onFrameRateSpeedUp = value;
}
public static void doCoolDown() {
if (coolDownFrameRate == null) {
scheduleFrameTimer?.cancel();
scheduleFrameTimer = instance.run(
new TimeSpan(0, 0, 0, 0, 200),
() => {
Application.targetFrameRate = defaultMinTargetFrameRate;
scheduleFrameTimer = null;
});
}
else {
coolDownFrameRate();
static void defaultFrateRateSpeedUp() {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
static Action _onFrameRateCoolDown = () => { defaultFrateRateCoolDown(); };
public static Action onFrameRateCoolDown {
get { return _onFrameRateCoolDown; }
set {
if (value == null) {
_onFrameRateCoolDown = () => { defaultFrateRateCoolDown(); };
}
else {
_onFrameRateCoolDown = value;
}
}
static void defaultFrateRateCoolDown() {
Application.targetFrameRate = defaultMinTargetFrameRate;
}
}
}
正在加载...
取消
保存