Table of Contents

Class AddressableLoadProcessor

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Central queue for Addressable asset and scene loading.

public static class AddressableLoadProcessor
Inheritance
AddressableLoadProcessor
Inherited Members

Remarks

Completion vs. progress. Callers learn that their work finished from the AddressableLoadBatch returned by BeginProcessQueue(). OnProgressUpdate is a display-only aggregate across everything in flight and must never be used to detect completion — it is global, so it fires for work the subscriber never requested.

Ordering. The drain processes assets before scenes within a pass. Code relies on this: bootstrap systems enqueue template labels and scenes together and expect the templates to be in the cache before a scene that references them deserializes.

Termination invariant. Every item that enters the queue must eventually call FinishAsset(AddressableAssetKey, bool) or FinishScene(string, bool) exactly once, on every path — success, failure, duplicate, or invalid handle. An item that leaves without being finished is never removed from the in-flight tables, so FishMMO.Shared.AddressableLoadProcessor.PendingItemCount never reaches zero, the drain loop never exits, and every batch waiting on it stalls forever.

Fields

OnAddressableLoaded

Invoked when an Addressable (non scene) is loaded.

public static Action<Object> OnAddressableLoaded

Field Value

Action<Object>

OnAddressableUnloaded

Invoked when an Addressable (non scene) is unloaded.

public static Action<Object> OnAddressableUnloaded

Field Value

Action<Object>

OnProgressUpdate

Aggregate progress across everything currently in flight, 0..1.

public static Action<float> OnProgressUpdate

Field Value

Action<float>

Remarks

Display only. This is global: it reports on work the subscriber did not request, and it fires 1 whenever the whole queue happens to drain. Do not use it to detect that your own load finished — use the AddressableLoadBatch returned by BeginProcessQueue().

OnSceneLoaded

Invoked when an Addressable Scene is loaded.

public static Action<Scene> OnSceneLoaded

Field Value

Action<Scene>

OnSceneUnloaded

Invoked when an Addressable Scene is unloaded.

public static Action<string> OnSceneUnloaded

Field Value

Action<string>

Properties

CurrentProgress

Aggregate progress of the current drain, 0..1.

public static float CurrentProgress { get; }

Property Value

float

Remarks

Divides by the run's total, not by the remaining count. The previous processed / remaining form produced 1/3, 2/2, 3/1, 4/0 for a four-item load — values at or above 1 from the halfway point on, which the caller then discarded, so bars never animated past the first item.

IsLoading

True while the drain is running.

public static bool IsLoading { get; }

Property Value

bool

Remarks

Lets a subscriber created mid-drain seed its own state instead of waiting for the next OnProgressUpdate tick. A loading screen living in a scene the processor is itself loading is exactly that case: every event raised before its Awake is lost, so without this it cannot tell "boot is still running" from "nothing is happening" until the next item happens to finish.

RemainingAssetsToLoad

Number of items still queued or in flight.

public static float RemainingAssetsToLoad { get; }

Property Value

float

Methods

BeginProcessQueue()

Claims everything enqueued since the previous call into a new batch and starts the drain if it is not already running.

public static AddressableLoadBatch BeginProcessQueue()

Returns

AddressableLoadBatch

A batch that completes when exactly the claimed items have finished. A batch with nothing to claim is already complete on return; subscribing to its Completed still invokes the handler.

Remarks

Safe to call while a drain is running: the new batch's items join the running drain and the batch completes when its own items finish, independently of any other batch.

EnqueueLoad(AddressableSceneLoadData, Action<Scene>)

Enqueues a single scene load operation. Optionally attaches a post-process callback.

public static void EnqueueLoad(AddressableSceneLoadData sceneLoadData, Action<Scene> globalOnScenePostProcess = null)

Parameters

sceneLoadData AddressableSceneLoadData

Scene load data to enqueue.

globalOnScenePostProcess Action<Scene>

Optional callback invoked after scene is loaded.

Remarks

When the same scene is enqueued twice before it loads, the callbacks are merged onto the queued request rather than the second request being dropped. The previous implementation deduped on scene name alone and silently discarded the second caller's callback along with it.

EnqueueLoad(IEnumerable<AddressableSceneLoadData>, Action<Scene>)

Enqueues multiple scene load operations. Optionally attaches a post-process callback to each.

public static void EnqueueLoad(IEnumerable<AddressableSceneLoadData> sceneLoadDatas, Action<Scene> globalOnScenePostProcess = null)

Parameters

sceneLoadDatas IEnumerable<AddressableSceneLoadData>

Enumerable of scene load data to enqueue.

globalOnScenePostProcess Action<Scene>

Optional callback invoked after each scene is loaded.

EnqueueLoad(IEnumerable<KeyValuePair<string, string>>, MergeMode)

Enqueues multiple label-key pairs for loading. Uses intersection merge mode by default.

public static void EnqueueLoad(IEnumerable<KeyValuePair<string, string>> labels, Addressables.MergeMode mergeMode = MergeMode.Intersection)

Parameters

labels IEnumerable<KeyValuePair<string, string>>

Enumerable of label-key pairs.

mergeMode Addressables.MergeMode

The merge mode for label processing.

EnqueueLoad(IEnumerable<string>, MergeMode)

Enqueues multiple addressable asset labels for loading. Ignores null or empty collections.

public static void EnqueueLoad(IEnumerable<string> labels, Addressables.MergeMode mergeMode = MergeMode.None)

Parameters

labels IEnumerable<string>

Enumerable of addressable labels to load.

mergeMode Addressables.MergeMode

The merge mode for label processing.

EnqueueLoad(string, string, MergeMode)

Enqueues a label and key pair for loading. Uses intersection merge mode by default.

public static void EnqueueLoad(string label, string key, Addressables.MergeMode mergeMode = MergeMode.Intersection)

Parameters

label string

The addressable label.

key string

The addressable key.

mergeMode Addressables.MergeMode

The merge mode for label processing.

EnqueueLoad(string, MergeMode)

Enqueues a single addressable asset label for loading.

public static void EnqueueLoad(string label, Addressables.MergeMode mergeMode = MergeMode.None)

Parameters

label string

The addressable label to load.

mergeMode Addressables.MergeMode

The merge mode for label processing.

IsSceneLoaded(string)

Returns true when a scene with the given name is currently tracked as loaded by this processor.

public static bool IsSceneLoaded(string sceneName)

Parameters

sceneName string

The scene name to test.

Returns

bool

LoadPrefabAsync(AssetReference, Action<GameObject>)

Loads a prefab asynchronously using an AssetReference. Invokes callback when load completes or fails.

public static void LoadPrefabAsync(AssetReference assetReference, Action<GameObject> onLoadComplete)

Parameters

assetReference AssetReference

The AssetReference to load.

onLoadComplete Action<GameObject>

Callback invoked with loaded GameObject or null on failure.

ReleaseAllAssets()

Releases all loaded assets, scenes, and prefabs managed by this processor and returns it to a clean idle state.

public static void ReleaseAllAssets()

Remarks

Also clears the pending queues, retires outstanding batches, and resets FishMMO.Shared.AddressableLoadProcessor.isProcessingQueue. Stopping the drain coroutine without clearing that flag left BeginProcessQueue() a permanent no-op, so nothing could ever load again in that session.

UnloadAssetByKey(AddressableAssetKey)

Unload a specific asset by its key.

public static void UnloadAssetByKey(AddressableAssetKey assetKey)

Parameters

assetKey AddressableAssetKey

UnloadPrefab(AssetReference)

Unloads a prefab asset previously loaded by this processor. Ignores if asset is still loading or not managed.

public static void UnloadPrefab(AssetReference assetReference)

Parameters

assetReference AssetReference

The AssetReference to unload.

UnloadSceneByLabelAsync(List<AddressableSceneLoadData>)

Unloads multiple scenes asynchronously using a list of AddressableSceneLoadData.

public static void UnloadSceneByLabelAsync(List<AddressableSceneLoadData> sceneLoadData)

Parameters

sceneLoadData List<AddressableSceneLoadData>

List of scene load data objects to unload.

UnloadSceneByLabelAsync(List<string>)

Unloads multiple scenes asynchronously by their names.

public static void UnloadSceneByLabelAsync(List<string> sceneNames)

Parameters

sceneNames List<string>

List of scene names to unload.

UnloadSceneByLabelAsync(string)

Unloads a scene asynchronously by its name. Invokes callback on completion or logs error on failure.

public static void UnloadSceneByLabelAsync(string sceneName)

Parameters

sceneName string

The name of the scene to unload.