OptimizationManager
A class in Root.Township, the global namespace.
Client singleton that steps graphics quality (LOD bias and shadows) up or down based on frame time. It follows the local player, so it only does anything on a client.
- Listed in Global namespace: M to O
- Inherits or implements
MonoBehaviour - Nested types
Direction,QualitySetting
Constructors
| Member | What it is |
|---|---|
OptimizationManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static OptimizationManager instance | The single instance, set in Awake. |
10 private and internal fields
| Member | What it is |
|---|---|
private float adjustmentDelay | Seconds to wait after a quality change before measuring again. |
private Coroutine coroutine | The running measuring coroutine, if any. |
private int currentLevel | Backing field for CurrentLevel. |
private int defaultLevel | Quality level applied on Awake. |
private int frameCountToStep | How many slow or fast frames in a row trigger a step. |
private int maxLevel | Highest quality level index. |
private OptimizationManager.QualitySetting[] qualityLevels | The quality presets, from best to cheapest. |
private OptimizationManager.Direction stepDirection | Pending step (performance up, still or graphics up) applied on the next player move. |
private float stepDownFPS | FPS below which quality is lowered (60 by default). |
private float stepUpFPS | FPS above which quality is raised (85 by default). |
Properties
| Member | What it is |
|---|---|
int CurrentLevel { get; } | Index of the quality level in use. Higher means lower quality. |
2 private and internal properties
Methods
| Member | What it is |
|---|---|
void Run() | Restarts the PerformanceMeasure coroutine. |
void Stop() | Stops the running measuring coroutine. |
7 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Sets instance, applies the default quality level, and hooks the local player's movement. |
private void OnDestroy() | Unhooks the local player events. |
private IEnumerator PerformanceMeasure() (iterator) | Coroutine started by Run: after enough slow or fast frames in a row it steps quality down or up, then waits. |
private IEnumerator PerformanceMeasureOnPosition() (iterator) | Coroutine that watches frame times and nudges stepDirection, which is applied the next time the player moves. |
private void Run(IPlayer player) | Restarts the PerformanceMeasure coroutine. |
private void UpdateLocalPlayer(PlayerController controller) | Hooks the local player's PositionChanged so quality steps happen when they move. |
private void UpdatePosition(PlayerController controller, Vector3 from, Vector3 to, LocomotionFunction function) | On player movement, applies any pending quality step and starts the position-based measuring coroutine. |