【m】框架大更新
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||
using YooAsset;
|
||||
|
||||
internal class APFSLoadBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadAssetBundle,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly AlipayFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private LoadWebAssetBundleOperation _loadWebAssetBundleOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal APFSLoadBundleOperation(AlipayFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadAssetBundle;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadAssetBundle)
|
||||
{
|
||||
if (_loadWebAssetBundleOp == null)
|
||||
{
|
||||
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadAlipayAssetBundleOperation(_bundle, options);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
}
|
||||
|
||||
_loadWebAssetBundleOp.UpdateOperation();
|
||||
Progress = _loadWebAssetBundleOp.Progress;
|
||||
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
||||
DownloadedBytes = _loadWebAssetBundleOp.DownloadedBytes;
|
||||
if (_loadWebAssetBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadWebAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
var assetBundle = _loadWebAssetBundleOp.Result;
|
||||
_steps = ESteps.Done;
|
||||
Result = new APAssetBundleResult(_fileSystem, _bundle, assetBundle);
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadWebAssetBundleOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
if (_steps != ESteps.Done)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "WebGL platform not support sync load method !";
|
||||
UnityEngine.Debug.LogError(Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user