Class ResourceSystem
Resource system that loads resource by address and label based on Addressables.
public static class ResourceSystem
- Inheritance
-
ResourceSystem
- Inherited Members
Fields
DynamicLoadPath
Dynamic load path placeholder for content catalog
public const string DynamicLoadPath = "{DYNAMIC_LOCAL_PATH}"
Field Value
Methods
EnsureAssetExistsAsync<TAsset>(IEnumerable, MergeMode)
Ensure resource location exists asynchronously. Throws InvalidResourceRequestException if not found.
public static UniTask EnsureAssetExistsAsync<TAsset>(IEnumerable key, ResourceSystem.MergeMode mergeMode)
Parameters
keyIEnumerablemergeModeResourceSystem.MergeMode
Returns
- UniTask
Type Parameters
TAsset
EnsureAssetExistsAsync<TAsset>(object)
Ensure resource location exists asynchronously. Throws InvalidResourceRequestException if not found.
public static UniTask EnsureAssetExistsAsync<TAsset>(object key)
Parameters
keyobject
Returns
- UniTask
Type Parameters
TAsset
EnsureAssetExists<TAsset>(IEnumerable, MergeMode)
Ensure resource location exists. Throws InvalidResourceRequestException if not found.
public static void EnsureAssetExists<TAsset>(IEnumerable key, ResourceSystem.MergeMode mergeMode)
Parameters
keyIEnumerablemergeModeResourceSystem.MergeMode
Type Parameters
TAsset
EnsureAssetExists<TAsset>(object)
Ensure resource location exists. Throws InvalidResourceRequestException if not found.
public static void EnsureAssetExists<TAsset>(object key)
Parameters
keyobject
Type Parameters
TAsset
GetAwaiter(ResourceHandle)
public static UniTask.Awaiter GetAwaiter(this ResourceHandle handle)
Parameters
handleResourceHandle
Returns
- UniTask.Awaiter
GetAwaiter<T>(ResourceHandle<T>)
public static UniTask<T>.Awaiter GetAwaiter<T>(this ResourceHandle<T> handle)
Parameters
handleResourceHandle<T>
Returns
- UniTask<T>.Awaiter
Type Parameters
T
GetCatalogExtension()
public static string GetCatalogExtension()
Returns
InstantiateAsync(string, Transform, Action<GameObject>)
Instantiate a single GameObject async
public static ResourceHandle<GameObject> InstantiateAsync(string address, Transform parent = null, Action<GameObject> callback = null)
Parameters
addressstringThe key of the location of the Object to instantiate.
parentTransformParent transform for instantiated object.
callbackAction<GameObject>Callback on instantiate complete
Returns
IsDone(ResourceHandle)
Whether internal operation is done
public static bool IsDone(this ResourceHandle handle)
Parameters
handleResourceHandle
Returns
IsDone<T>(ResourceHandle<T>)
Whether internal operation is done
public static bool IsDone<T>(this ResourceHandle<T> handle)
Parameters
handleResourceHandle<T>
Returns
Type Parameters
T
IsValid(ResourceHandle)
Whether internal operation is valid
public static bool IsValid(this ResourceHandle handle)
Parameters
handleResourceHandle
Returns
IsValid<T>(ResourceHandle<T>)
Whether internal operation is valid
public static bool IsValid<T>(this ResourceHandle<T> handle)
Parameters
handleResourceHandle<T>
Returns
Type Parameters
T
LoadAssetAsync<T>(string, Action<T>)
Load asset async
public static ResourceHandle<T> LoadAssetAsync<T>(string address, Action<T> callBack = null)
Parameters
Returns
Type Parameters
T
LoadAssetsAsync<T>(IEnumerable, MergeMode, Action<IList<T>>)
public static ResourceHandle<IList<T>> LoadAssetsAsync<T>(IEnumerable key, ResourceSystem.MergeMode mode, Action<IList<T>> callBack = null)
Parameters
keyIEnumerablemodeResourceSystem.MergeModecallBackAction<IList<T>>
Returns
- ResourceHandle<IList<T>>
Type Parameters
T
LoadAssetsAsync<T>(object, Action<IList<T>>)
public static ResourceHandle<IList<T>> LoadAssetsAsync<T>(object key, Action<IList<T>> callBack = null)
Parameters
Returns
- ResourceHandle<IList<T>>
Type Parameters
T
LoadCatalog(string)
Load Addressables content catalog from path.
public static bool LoadCatalog(string path)
Parameters
pathstringCan be folder path or catalog path
Returns
LoadCatalogAsync(string)
Load Addressables content catalog asynchronously from path.
public static UniTask<bool> LoadCatalogAsync(string path)
Parameters
pathstringCan be folder path or catalog path
Returns
- UniTask<bool>
Release(ResourceHandle)
Release resource
public static void Release(ResourceHandle handle)
Parameters
handleResourceHandle
ReleaseAsset(ResourceHandle)
Release Asset, should align with LoadAssetAsync<T>(string, Action<T>)
public static void ReleaseAsset(ResourceHandle handle)
Parameters
handleResourceHandle
ReleaseInstance(GameObject)
Release GameObject Instance, should align with InstantiateAsync(string, Transform, Action<GameObject>)
public static void ReleaseInstance(GameObject gameObject)
Parameters
gameObjectGameObject
Release<T>(ResourceHandle<T>)
Release resource
public static void Release<T>(ResourceHandle<T> handle)
Parameters
handleResourceHandle<T>
Type Parameters
T
ToResourceHandle<T>(AssetReferenceT<T>)
Load asset async by UnityEngine.AddressableAssets.AssetReferenceT<TObject> and convert to ResourceHandle<T>
public static ResourceHandle<T> ToResourceHandle<T>(this AssetReferenceT<T> assetReferenceT) where T : Object
Parameters
assetReferenceTAssetReferenceT<T>
Returns
Type Parameters
T
ToUniTask(ResourceHandle)
public static UniTask ToUniTask(this ResourceHandle handle)
Parameters
handleResourceHandle
Returns
- UniTask
ToUniTask<T>(ResourceHandle<T>)
public static UniTask<T> ToUniTask<T>(this ResourceHandle<T> handle)
Parameters
handleResourceHandle<T>
Returns
- UniTask<T>
Type Parameters
T
WithCancellation(ResourceHandle, CancellationToken, bool, bool)
public static UniTask WithCancellation(this ResourceHandle handle, CancellationToken cancellationToken, bool cancelImmediately = false, bool autoReleaseWhenCanceled = false)
Parameters
handleResourceHandlecancellationTokenCancellationTokencancelImmediatelyboolautoReleaseWhenCanceledbool
Returns
- UniTask
WithCancellation<T>(ResourceHandle<T>, CancellationToken, bool, bool)
public static UniTask<T> WithCancellation<T>(this ResourceHandle<T> handle, CancellationToken cancellationToken, bool cancelImmediately = false, bool autoReleaseWhenCanceled = false)
Parameters
handleResourceHandle<T>cancellationTokenCancellationTokencancelImmediatelyboolautoReleaseWhenCanceledbool
Returns
- UniTask<T>
Type Parameters
T