浏览代码

Move speedUpFrameRate and coolDownFrameRate into Window.

/main
Yuncong Zhang 6 年前
当前提交
c3af4286
共有 4 个文件被更改,包括 34 次插入45 次删除
  1. 4
      Runtime/editor/editor_window.cs
  2. 32
      Runtime/ui/window.cs
  3. 40
      Runtime/engine/global_settings.cs
  4. 3
      Runtime/engine/global_settings.cs.meta

4
Runtime/editor/editor_window.cs


if (regenerateLayerTree) {
this._regenerateLayerTree = true;
}
UIWidgetsGlobalSettings.instance.speedUpFrameRate();
UIWidgetsGlobalSettings.instance.coolDownFrameRate();
doSpeedUp();
doCoolDown();
}
public override void render(Scene scene) {

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

public float getFPS() {
return 1.0f / this.fpsDeltaTime;
}
public static Action speedUpFrameRate;
public static Action coolDownFrameRate;
static Timer scheduleFrameTimer;
public const int defaultMaxTargetFrameRate = 60;
public const int defaultMinTargetFrameRate = 15;
public static void doSpeedUp() {
if (speedUpFrameRate == null) {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
else {
speedUpFrameRate();
}
}
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();
}
}
}
}

40
Runtime/engine/global_settings.cs


using System;
using Unity.UIWidgets.async;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.engine {
public class UIWidgetsGlobalSettings {
UIWidgetsGlobalSettings() {
this.speedUpFrameRate = () => { this.defaultSpeedUp(); };
this.coolDownFrameRate = () => { this.defaultCoolDown(); };
}
public Action speedUpFrameRate;
public Action coolDownFrameRate;
public static UIWidgetsGlobalSettings instance {
get { return _instance; }
}
static UIWidgetsGlobalSettings _instance = new UIWidgetsGlobalSettings();
Timer scheduleFrameTimer;
public const int defaultMaxTargetFrameRate = 60;
public const int defaultMinTargetFrameRate = 15;
void defaultSpeedUp() {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
void defaultCoolDown() {
this.scheduleFrameTimer?.cancel();
this.scheduleFrameTimer = Window.instance.run(
new TimeSpan(0, 0, 0, 0, 200),
() => {
Application.targetFrameRate = defaultMinTargetFrameRate;
this.scheduleFrameTimer = null;
});
}
}
}

3
Runtime/engine/global_settings.cs.meta


fileFormatVersion: 2
guid: 3ffd4ed5bc5c4758b56f365a50418fff
timeCreated: 1554884592
正在加载...
取消
保存