Struct ManagedAddressableList<T>
A value-type RAII wrapper that holds a batch of loaded Addressable assets and automatically
releases the underlying AsyncOperationHandle when the wrapper is disposed, ensuring that
all assets in the batch have their Addressables reference count decremented simultaneously.
Inherited Members
Namespace: Scylla.Core.Util.Addressables
Assembly: ScyllaCore.dll
Syntax
public struct ManagedAddressableList<T> : IDisposable, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| T | The common asset type shared by all assets in the batch (e.g. |
Remarks
Instances are created exclusively by LoadAllManagedAsync<T>(string, CancellationToken) and LoadAllManagedAsync<T>(IList<string>, CancellationToken).
IReadOnlyList implementation. This struct implements IReadOnlyList<T>,
allowing direct enumeration with foreach and index-based access via this[int].
Both are safe to use while IsValid is true and throw
InvalidOperationException after disposal.
Value-type copy semantics. Like ManagedAddressable<T>, this is a struct; copies share the same underlying handle. Disposing either copy releases the shared handle for the entire batch.
Properties
Assets
Gets all loaded assets as a read-only list.
Declaration
public IReadOnlyList<T> Assets { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<T> | The |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Dispose() has already been called, or when the underlying handle is no longer valid. |
Count
Gets the number of assets in the batch.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The count of assets in the loaded list, or |
Handle
Gets the raw AsyncOperationHandle that this wrapper manages.
Declaration
public AsyncOperationHandle<IList<T>> Handle { get; }
Property Value
| Type | Description |
|---|---|
| AsyncOperationHandle<IList<T>> | The batch-load handle wrapping |
IsValid
Gets a value indicating whether this wrapper holds a valid, unreleased batch of Addressable assets.
Declaration
public bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
this[int]
Gets the asset at the specified index within the loaded batch.
Declaration
public T this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the asset to retrieve. Must be within the range
|
Property Value
| Type | Description |
|---|---|
| T | The asset at |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Dispose() has already been called or the handle is invalid. |
| ArgumentOutOfRangeException | Thrown by the underlying list when |
Methods
Dispose()
Releases the underlying Addressables batch-load handle, decrementing the reference count for all assets in the batch simultaneously. Subsequent calls are safe no-ops.
Declaration
public void Dispose()
Remarks
After disposal, IsValid returns false, Count returns 0,
and accessing Assets or the indexer will throw InvalidOperationException.
GetEnumerator()
Returns an enumerator that iterates through all assets in the batch.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<T> | An enumerator over the loaded assets. If the wrapper has been disposed, the handle is invalid,
or the result list is |