浏览代码

Use UIWidgetsGlobalSettings.

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

3
Runtime/editor/editor_window.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;

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

20
Runtime/engine/UIWidgetsPanel.cs


public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
this._needsPaint = true;
this._uiWidgetsPanel.speedUpFrameRate();
this._uiWidgetsPanel.coolDownFrameRate();
}
public UIWidgetWindowAdapter(UIWidgetsPanel uiWidgetsPanel) {

Texture _texture;
Vector2 _lastMouseMove;
Timer scheduleFrameTimer;
public const int defaultMaxTargetFrameRate = 60;
public const int defaultMinTargetFrameRate = 15;
readonly HashSet<int> _enteredPointers = new HashSet<int>();
bool _viewMetricsCallbackRegistered;

public Window window {
get { return this._windowAdapter; }
}
public virtual void speedUpFrameRate() {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
public virtual void coolDownFrameRate() {
this.scheduleFrameTimer?.cancel();
this.scheduleFrameTimer = this.window.run(
new TimeSpan(0, 0, 0, 0, 200),
() => {
Application.targetFrameRate = defaultMinTargetFrameRate;
this.scheduleFrameTimer = null;
});
}
}
}

34
Runtime/engine/global_settings.cs


using System;
using Unity.UIWidgets.async;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.engine {
public class UIWidgetsGlobalSettings {
private UIWidgetsGlobalSettings() {}
static UIWidgetsGlobalSettings _instance = new UIWidgetsGlobalSettings();
Timer scheduleFrameTimer;
public const int defaultMaxTargetFrameRate = 60;
public const int defaultMinTargetFrameRate = 15;
public static UIWidgetsGlobalSettings instance {
get { return _instance; }
}
public virtual void speedUpFrameRate() {
Application.targetFrameRate = defaultMaxTargetFrameRate;
}
public virtual void coolDownFrameRate() {
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
正在加载...
取消
保存