Skip to content

Commit 6bc809c

Browse files
committed
updated sample, readme, update remainder old code
1 parent ae90374 commit 6bc809c

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,33 @@ BundleSystem.BundledAssetPath MyAsset;
229229
}
230230
```
231231

232+
\
233+
**Async/Await Examples**
234+
```cs
235+
async Task AsyncAwaitSamples()
236+
{
237+
//initialize with task aupport
238+
{
239+
//initialize bundle system & load local bundles
240+
await BundleManager.Initialize();
241+
242+
//get download size from latest bundle manifest
243+
var manifestReq = await BundleManager.GetManifest();
244+
if (!manifestReq.Succeeded)
245+
{
246+
//handle error
247+
Debug.LogError(manifestReq.ErrorCode);
248+
}
249+
250+
//load asset with async/await
251+
using (var loadReq = await BundleManager.LoadAsync<GameObject>("Prefab", "PrefabName"))
252+
{
253+
var instance = BundleManager.Instantiate(loadReq.Asset);
254+
}
255+
}
256+
}
257+
```
258+
232259
\
233260
**Editor Test Script**
234261
```cs

Runtime/BundleManager.Memory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static IEnumerator ReloadBundle(string bundleName, LoadedBundle loadedBundle)
306306
yield return bundleReq.SendWebRequest();
307307
loadedBundle.IsReloading = false;
308308

309-
if (bundleReq.isNetworkError || bundleReq.isHttpError)
309+
if (!Utility.CheckRequestSuccess(bundleReq))
310310
{
311311
Debug.LogError($"Bundle reload error { bundleReq.error }");
312312
yield break;

Samples~/Sample/ApiSampleScript/LocusBundleSample.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using UnityEngine;
33
using BundleSystem;
4+
using System.Threading.Tasks;
45

56
public class LocusBundleSample : MonoBehaviour
67
{
@@ -111,6 +112,34 @@ IEnumerator ApiSamples()
111112
}
112113
}
113114

115+
async Task AsyncAwaitSamples()
116+
{
117+
//initialize with task aupport
118+
{
119+
//show log message
120+
BundleManager.LogMessages = true;
121+
122+
//show some ongui elements for debugging
123+
BundleManager.ShowDebugGUI = true;
124+
125+
//initialize bundle system & load local bundles
126+
await BundleManager.Initialize();
127+
128+
//get download size from latest bundle manifest
129+
var manifestReq = await BundleManager.GetManifest();
130+
if (!manifestReq.Succeeded)
131+
{
132+
//handle error
133+
Debug.LogError(manifestReq.ErrorCode);
134+
}
135+
136+
//load asset with async/await
137+
using (var loadReq = await BundleManager.LoadAsync<GameObject>("Prefab", "PrefabName"))
138+
{
139+
var instance = BundleManager.Instantiate(loadReq.Asset);
140+
}
141+
}
142+
}
114143

115144
IEnumerator AdvancedApiSamples()
116145
{

0 commit comments

Comments
 (0)