Skip to main content

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.

Constructors​

MemberWhat it is
UnityUpdateManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private List<UpdateModule> fixedUpdateModulesModules run in FixedUpdate.
private bool isProfilingBacking field for IsProfiling.
private List<UpdateModule> lateUpdateModulesModules run in LateUpdate.
private float sharedBudgetedUpdateMsAllowanceMilliseconds per frame given to BudgetedUpdateModule.
private static List<UnityUpdateManager.ModuleRegistration> startUpModulesModules registered before the manager existed, waiting for Awake.
private List<UpdateModule> updateModulesModules run in Update.
private bool verifyAllCountsInspector button that runs VerifyAllCounts.

Properties​

MemberWhat 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​

MemberWhat 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
MemberWhat 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.