Give Page Feedback | API

Component Managers - Public API

Most of the useful API has already been covered by the other Sections within this Chapter. This Section covers the rest (except for a few properties which could be useful but aren't worth mentioning here - view the full API using the link above for full details).

Iterating Over Components (Garbage Free)

You can iterate over all Worlds and/or Active Grids in the scene in a garbage free way using the WorldsInScene and/or ActiveGridsInScene methods. These methods return a Dictionary.ValueCollection which is a simple wrapper around the Dictionary that does not generate garbage. You can iterate over this collection manually or use it in a foreach statement.

Getting Components By ID

In many situations you can avoid having to manually assign World and Active Grid references in the inspector by making use of the IDs of these components. To do so, simply use the TryGetWorldByID and/or TryGetActiveGridByID methods.

Unloading Everything

If you need to unload all Worlds and Active Grids from the current scene, you can do so using the DestroyActiveGridsAndWorldsAndUnloadWorldCells method. This is an enumerator based method that you must run manually or via StartCoroutine.

We recommend running this method before loading persistent save data from an already initialized scene (with an already initialized Component Manager). This will ensure all game objects, components, and assets related to the old persistent data are cleared from the scene before loading the new persistent data.

Tracking Load Progress

When you Initialize the Component Manager in a gradual manner, the progress of Active Grid and World initialization is tracked automatically via the InitializationProgress property. This value goes from 0 to 1f and allows you to display a fairly time accurate loading bar while initialization is in progress. The progress is set to 1f just before subscribers to the ComponentManagerInitialized event are notified. While we recommend timing the removal of loading screens to the full completion of the InitializeGradually method, it should be safe to use the InitializationProgress (when = to 1f) for this purpose.

ComponentManagerInitialized Event

This is a special event that is fired when the Component Manager completes initialization. You can use it in scripts that are not responsible for triggering the initialization, but that still want to be notified when it happens. Because the event is only fired once, it is cleared and nulled out after firing. As such, you do not need to worry about unsubscribing from the event (in fact, doing so will throw a NullReferenceException)