12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public class ManifestRequest : AssetRequest
- {
- private string assetName;
- private BundleRequest request;
- public int version { get; private set; }
- public override float progress
- {
- get
- {
- if (isDone)
- return 1;
- if (LoadState == AssetLoadState.Init)
- return 0;
- if (request == null)
- return 1;
- return request.progress;
- }
- }
- internal override void Load()
- {
- assetName = Path.GetFileName(name);
- if (LoadModule.runtimeMode)
- {
- var assetBundleName = assetName.Replace("", "").ToLower();
- request = LoadModule.LoadBundleAsync(assetBundleName);
- }
- else
- {
- LoadState = AssetLoadState.Loaded;
- }
- }
- internal override bool Update()
- {
- if (!base.Update())
- return false;
- if (LoadState == AssetLoadState.Init)
- return true;
- if(request == null)
- {
- LoadState = AssetLoadState.Loaded;
- error = "request == null";
- return false;
- }
- if (request.isDone)
- {
- if(request.assetBundle == null)
- {
- error = "assetBundle == null";
- }
- else
- {
- var manifest = request.assetBundle.LoadAsset<Manifest>(assetName);
- if (manifest == null)
- error = "manifest == null";
- else
- LoadModule.OnManifestLoaded(manifest);
- }
- LoadState = AssetLoadState.Loaded;
- return false;
- }
- return true;
- }
- }
|