Class AssetSystem
IAssetSystem 구현체. AddressablesAdapter(로드/해제) + AssetCacheSystem(캐시) 내부 조합.
public class AssetSystem : IAssetSystem, IInitializable
- Inheritance
-
objectAssetSystem
- Implements
Remarks
LoadAsync: 캐시 히트 시 즉시 반환. 미스 시 AddressablesAdapter로 비동기 로드 후 캐시 저장. 로드 결과가 null이면 캐시에 저장하지 않고 Error 로그 출력. 예외 발생 시 ExceptionHandler를 통해 Error 처리 후 null 반환. Release: AddressablesAdapter에서 핸들 해제 + 캐시에서 제거 동시 수행. [규칙] Preload는 State.OnEnterAsync에서, 해제는 State.OnExitAsync 또는 Scope Dispose에서.
Constructors
AssetSystem(IAssetCache, ILogSystem, IExceptionHandler)
public AssetSystem(IAssetCache cache, ILogSystem log, IExceptionHandler exceptionHandler)
Parameters
cacheIAssetCachelogILogSystemexceptionHandlerIExceptionHandler
Methods
Dispose()
public void Dispose()
InitializeAsync(CancellationToken)
Addressables 런타임 초기화. 현재는 no-op (AddressablesAdapter.InitializeAsync 필요 시 호출).
public UniTask InitializeAsync(CancellationToken ct = default)
Parameters
ctCancellationToken
Returns
- UniTask
IsCached(string)
해당 키의 에셋이 현재 캐시에 존재하는지 확인.
public bool IsCached(string key)
Parameters
keystring확인할 에셋 키.
Returns
- bool
캐시 존재 여부.
LoadAsync<T>(string, CancellationToken)
에셋 비동기 로드. 이미 캐시된 경우 즉시 반환.
public UniTask<T> LoadAsync<T>(string key, CancellationToken ct = default) where T : Object
Parameters
keystringAddressable 에셋 키. AddressableKeys 상수 사용.
ctCancellationToken로드 취소 신호.
Returns
- UniTask<T>
로드된 에셋. 실패 시 null (로그 출력됨).
Type Parameters
T로드할 에셋 타입 (GameObject, AudioClip, ScriptableObject 등).
Release(string)
에셋 해제 및 캐시에서 제거. 반드시 사용 완료 후 호출.
public void Release(string key)
Parameters
keystring해제할 에셋 키.