Method GetOrLoadAsync
GetOrLoadAsync<T>(string, AssetTier, CancellationToken)
The only way to load: waits for the asset (async, never blocks) and returns it, cache and reference counting included. A cache hit returns the resident object without touching Addressables at all.
There is deliberately no synchronous counterpart. The blocking path does not exist on WebGL -
AsyncOperationBase.WaitForCompletion() throws on any platform without threads - so a sync loader
can only ever fail there, and it fails quietly: the old GetOrLoad caught that throw, logged and
returned null, which is how 34 item prefabs came back null in a browser on code that worked on the
desktop. Two verbs are the whole API: Get<T>(string) for something a preload stage already owns,
and this for everything else.
public static Task<T> GetOrLoadAsync<T>(string address, AssetTier tier = AssetTier.Definition, CancellationToken ct = default) where T : Object
Parameters
addressstringtierAssetTierctCancellationToken
Returns
- Task<T>
Type Parameters
T