UnityUpdateManager
A class in Root.Township, the global namespace.
The one MonoBehaviour that drives the game's update modules: it runs every registered UpdateModule in Unity's Update, LateUpdate and FixedUpdate. Most code registers methods on the shared static modules instead of having its own Update. Reach it through Instance.
- Listed in Global namespace: T to X
- Inherits or implements
MonoBehaviour - Nested types
ModuleRegistration - Documented in Update modules
Constructors
| Member | What it is |
|---|---|
UnityUpdateManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private List<UpdateModule> fixedUpdateModules | Modules run in FixedUpdate. |
private bool isProfiling | Backing field for IsProfiling. |
private List<UpdateModule> lateUpdateModules | Modules run in LateUpdate. |
private float sharedBudgetedUpdateMsAllowance | Milliseconds per frame given to BudgetedUpdateModule. |
private static List<UnityUpdateManager.ModuleRegistration> startUpModules | Modules registered before the manager existed, waiting for Awake. |
private List<UpdateModule> updateModules | Modules run in Update. |
private bool verifyAllCounts | Inspector button that runs VerifyAllCounts. |
Properties
| Member | What it is |
|---|---|
static Dictionary<string, UpdateModuleInfo> AllModuleInfos { get; } | Profiling info for every module included in server profiling, keyed by module name. |
IEnumerable<UpdateModule> AllModules { get; } | Every registered module: update, then fixed update, then late update. |
static BudgetedUpdateModule BudgetedUpdateModule { get; } | Shared Update-segment module that spends at most a set number of milliseconds a frame on its methods. |
static UpdateModule FixedUpdateModule { get; } | Shared module that runs in FixedUpdate. |
static UnityUpdateManager Instance { get; private set; } | The update manager in the scene. |
static bool IsProfiling { get; set; } | Turns profiling on or off for all modules. |
static UpdateModule LateUpdateModule { get; } | Shared module that runs in LateUpdate. |
static UpdateModule UpdateModule { get; } | Shared module that runs in Update. Register a method with RegisterMethod and keep the handle to deregister. |
Methods
| Member | What it is |
|---|---|
static void RegisterModule(UpdateModule module, UpdateSegment updateSegment) | Adds a module to a segment; if the manager doesn't exist yet, queues it until Awake. |
void RegisterModuleToList(UpdateModule module, UpdateSegment type) | Adds a module to the list for its segment and to AllModuleInfos if it's profiled; logs an error on a duplicate name. |
7 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Becomes Instance, registers modules queued before it existed, sets the shared budget and applies the profiling flag. |
private void FixedUpdate() | Runs every fixed update module. |
private void LateUpdate() | Runs every late update module. |
private void OnValidate() | Editor: reapplies profiling and runs the count check when its button is pressed. |
private void SetProfiling() | Pushes the isProfiling flag to every module. |
private void Update() | Runs every update module. |
private void VerifyAllCounts() | Logs each module's registered method count against its actual count, as an error when they differ. |