Skip to content

Commit 62e1f2b

Browse files
committed
feat(AddressableSystem): 添加 LoadAsset 同步加载方法
- 在 AddressableSystem 接口中新增了 LoadAsset<T>(string path) 方法 - 实现了该方法,使用 Addressables.LoadAssetAsync<T>(path) 加载资源并等待完成 - 该方法提供了一种同步加载资源的方式,补充了原有的异步加载功能
1 parent 56852fc commit 62e1f2b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CrazyCarClient/Assets/Scripts/System/AddressableSystem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public interface IAddressableSystem : ISystem {
1818
public void GetDownloadAssets();
1919
public void DownloadAsset();
2020
public UniTask<AsyncOperationHandle<T>> LoadAssetAsync<T>(string path);
21+
public AsyncOperationHandle<T> LoadAsset<T>(string path);
2122
public void SetUpdateInfo(Action finish);
2223
}
2324

@@ -144,6 +145,12 @@ public async UniTask<AsyncOperationHandle<T>> LoadAssetAsync<T>(string path){
144145
await obj;
145146
return obj;
146147
}
148+
149+
public AsyncOperationHandle<T> LoadAsset<T>(string path) {
150+
AsyncOperationHandle<T> obj = Addressables.LoadAssetAsync<T>(path);
151+
obj.WaitForCompletion();
152+
return obj;
153+
}
147154

148155
protected override void OnInit() {
149156

0 commit comments

Comments
 (0)