您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
34 行
1.1 KiB
34 行
1.1 KiB
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;
|
|
});
|
|
}
|
|
}
|
|
}
|