Skip to main content

AssetPoolManager

Singleton MonoBehaviour responsible for loading and managing the global AssetPool from an Addressable reference. Acts as the runtime gatekeeper for accessing avatar items, quests, emotes, and more.

[DefaultExecutionOrder(-100)]
public class AssetPoolManager : MonoBehaviour
warning

This service is due to be abstractified out to a pure C# functionality, removing the need for a MonoBehaviour singleton. These docs MIGHT be outdated... Or we might have other things we've done instead. Proceed with caution!


Purpose

  • Ensures the AssetPool is loaded early and only once
  • Handles addressable loading and unloading
  • Exposes status flags and utilities to defer execution until assets are ready

Fields

AssetReference assetPoolAddressable

Reference to the addressable AssetPool ScriptableObject asset.

AssetPool assetPool { get; private set; }

Loaded asset reference after resolution.

static AssetPoolManager instance

Global singleton instance for centralized access.

static Status CurrentStatus

Returns the current pool loading state (NOT_READY, LOADING, READY).

static AssetPool Pool

Shorthand for accessing the resolved pool instance.


Core Methods

static void Fetch()

Triggers async addressable loading of the AssetPool.

void PoolIsReady(AssetPool pool)

Caches the loaded pool and marks the manager as ready. Also runs GatherPacks().

static void WaitForAssets(Action callback)

Runs a callback immediately if the pool is loaded, or queues it to run after load completes.

static IEnumerator WaitForAssetsRoutine(Action callback)

Coroutine version of WaitForAssets for deferred asset-availability logic.


Unity Lifecycle

Awake()

Initializes the singleton and cleans up any pre-existing instance.

OnApplicationQuit()

Unloads the asset reference and clears state for shutdown or re-entry.


Usage Example

AssetPoolManager.WaitForAssets(() =>
{
var item = AssetPoolManager.Pool.GetPlayerItemByID("hat_45");
Equip(item);
});
if (AssetPoolManager.CurrentStatus == AssetPoolManager.Status.READY)
{
var packs = AssetPoolManager.Pool.PlayerItemPacks;
}

This manager ensures the massive content registry in AssetPool is loaded safely, without blocking startup or risking null references.