mirror of https://github.com/tuyoogame/YooAsset
Compare commits
4 Commits
5fa9ebee80
...
bf1e3da298
Author | SHA1 | Date |
---|---|---|
何冠峰 | bf1e3da298 | |
何冠峰 | a91cbee50c | |
何冠峰 | 15fbbf3873 | |
何冠峰 | f73abba79f |
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bf1355f3cbe3d543b53bd9553bba02c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,162 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Web文件系统
|
||||||
|
/// </summary>
|
||||||
|
internal class DefaultWebRemoteFileSystem : IFileSystem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件根目录
|
||||||
|
/// </summary>
|
||||||
|
public string FileRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件数量
|
||||||
|
/// </summary>
|
||||||
|
public int FileCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 自定义参数
|
||||||
|
/// <summary>
|
||||||
|
/// 禁用Unity的网络缓存
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableUnityWebCache { private set; get; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:跨域下载服务接口
|
||||||
|
/// </summary>
|
||||||
|
public IRemoteServices RemoteServices { private set; get; } = null;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public DefaultWebRemoteFileSystem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||||
|
{
|
||||||
|
var operation = new DWRFSInitializeOperation(this);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new DWRFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
||||||
|
{
|
||||||
|
var operation = new FSClearAllBundleFilesCompleteOperation();
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
||||||
|
{
|
||||||
|
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
var operation = new DWRFSLoadAssetBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||||
|
{
|
||||||
|
AssetBundle assetBundle = result as AssetBundle;
|
||||||
|
if (assetBundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (assetBundle != null)
|
||||||
|
assetBundle.Unload(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetParameter(string name, object value)
|
||||||
|
{
|
||||||
|
if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE)
|
||||||
|
{
|
||||||
|
DisableUnityWebCache = (bool)value;
|
||||||
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.REMOTE_SERVICES)
|
||||||
|
{
|
||||||
|
RemoteServices = (IRemoteServices)value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual void OnCreate(string packageName, string rootDirectory)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
}
|
||||||
|
public virtual void OnUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Belong(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual byte[] ReadFileData(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
public virtual string ReadFileText(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 内部方法
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f511714bfc7c1104aa6200ee0826e9e3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1086ea45b8b84fe43ba1ef69b4f813dc
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class DWRFSInitializeOperation : FSInitializeFileSystemOperation
|
||||||
|
{
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
|
||||||
|
public DWRFSInitializeOperation(DefaultWebRemoteFileSystem fileSystem)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f30b92e4f3b9e594ca0481128b56cc21
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class DWRFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
DownloadFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly PackageBundle _bundle;
|
||||||
|
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
internal DWRFSLoadAssetBundleOperation(DefaultWebRemoteFileSystem fileSystem, PackageBundle bundle)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_bundle = bundle;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.DownloadFile;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.DownloadFile)
|
||||||
|
{
|
||||||
|
if (_downloadhanlderAssetBundleOp == null)
|
||||||
|
{
|
||||||
|
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
||||||
|
downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||||
|
downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
|
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadhanlderAssetBundleOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadProgress = _downloadhanlderAssetBundleOp.DownloadProgress;
|
||||||
|
DownloadedBytes = _downloadhanlderAssetBundleOp.DownloadedBytes;
|
||||||
|
Progress = _downloadhanlderAssetBundleOp.Progress;
|
||||||
|
if (_downloadhanlderAssetBundleOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloadhanlderAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Result = _downloadhanlderAssetBundleOp.Result;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _downloadhanlderAssetBundleOp.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void AbortDownloadOperation()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.DownloadFile)
|
||||||
|
{
|
||||||
|
if (_downloadhanlderAssetBundleOp != null)
|
||||||
|
_downloadhanlderAssetBundleOp.SetAbort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 270b776fd379b0f45bc602c845720733
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,68 +1,44 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DWFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
internal class DWRFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
RequestWebPackageVersion,
|
|
||||||
RequestWebPackageHash,
|
RequestWebPackageHash,
|
||||||
LoadWebPackageManifest,
|
LoadWebPackageManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private RequestWebPackageVersionOperation _requestWebPackageVersionOp;
|
private RequestWebRemotePackageHashOperation _requestWebPackageHashOp;
|
||||||
private RequestWebPackageHashOperation _requestWebPackageHashOp;
|
private LoadWebRemotePackageManifestOperation _loadWebPackageManifestOp;
|
||||||
private LoadWebPackageManifestOperation _loadWebPackageManifestOp;
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
public DWFSLoadPackageManifestOperation(DefaultWebFileSystem fileSystem, int timeout)
|
public DWRFSLoadPackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestWebPackageVersion;
|
_steps = ESteps.RequestWebPackageHash;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.RequestWebPackageVersion)
|
|
||||||
{
|
|
||||||
if (_requestWebPackageVersionOp == null)
|
|
||||||
{
|
|
||||||
_requestWebPackageVersionOp = new RequestWebPackageVersionOperation(_fileSystem, _timeout);
|
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_requestWebPackageVersionOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.RequestWebPackageHash;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _requestWebPackageVersionOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.RequestWebPackageHash)
|
if (_steps == ESteps.RequestWebPackageHash)
|
||||||
{
|
{
|
||||||
if (_requestWebPackageHashOp == null)
|
if (_requestWebPackageHashOp == null)
|
||||||
{
|
{
|
||||||
string packageVersion = _requestWebPackageVersionOp.PackageVersion;
|
_requestWebPackageHashOp = new RequestWebRemotePackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||||
_requestWebPackageHashOp = new RequestWebPackageHashOperation(_fileSystem, packageVersion, _timeout);
|
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageHashOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageHashOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +61,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_loadWebPackageManifestOp == null)
|
if (_loadWebPackageManifestOp == null)
|
||||||
{
|
{
|
||||||
string packageVersion = _requestWebPackageVersionOp.PackageVersion;
|
|
||||||
string packageHash = _requestWebPackageHashOp.PackageHash;
|
string packageHash = _requestWebPackageHashOp.PackageHash;
|
||||||
_loadWebPackageManifestOp = new LoadWebPackageManifestOperation(_fileSystem, packageVersion, packageHash);
|
_loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadWebPackageManifestOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadWebPackageManifestOp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2611f6fbc97de1a4d9a38116045d4faf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class DWRFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly bool _appendTimeTicks;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private RequestWebRemotePackageVersionOperation _requestWebPackageVersionOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
internal DWRFSRequestPackageVersionOperation(DefaultWebRemoteFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_appendTimeTicks = appendTimeTicks;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestPackageVersion;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageVersion)
|
||||||
|
{
|
||||||
|
if (_requestWebPackageVersionOp == null)
|
||||||
|
{
|
||||||
|
_requestWebPackageVersionOp = new RequestWebRemotePackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _requestWebPackageVersionOp.Progress;
|
||||||
|
if (_requestWebPackageVersionOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
PackageVersion = _requestWebPackageVersionOp.PackageVersion;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _requestWebPackageVersionOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d1c5335974b2432458ed902e20cc954e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9be3163f53935514d9e64e09686db957
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,122 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class LoadWebRemotePackageManifestOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestFileData,
|
||||||
|
VerifyFileData,
|
||||||
|
LoadManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly string _packageHash;
|
||||||
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
|
private DeserializeManifestOperation _deserializer;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹清单
|
||||||
|
/// </summary>
|
||||||
|
public PackageManifest Manifest { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_packageHash = packageHash;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(LoadWebRemotePackageManifestOperation));
|
||||||
|
_steps = ESteps.RequestFileData;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestFileData)
|
||||||
|
{
|
||||||
|
if (_webDataRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
|
||||||
|
string url = GetWebRequestURL(fileName);
|
||||||
|
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _webDataRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_webDataRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.VerifyFileData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webDataRequestOp.Error;
|
||||||
|
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(LoadWebRemotePackageManifestOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.VerifyFileData)
|
||||||
|
{
|
||||||
|
string fileHash = HashUtility.BytesMD5(_webDataRequestOp.Result);
|
||||||
|
if (fileHash == _packageHash)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Failed to verify web remote package manifest file!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadManifest)
|
||||||
|
{
|
||||||
|
if (_deserializer == null)
|
||||||
|
{
|
||||||
|
_deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _deserializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _deserializer.Progress;
|
||||||
|
if (_deserializer.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Manifest = _deserializer.Manifest;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _deserializer.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetWebRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8ac57bde14f2e1a4e9323751a7157ed7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class RequestWebRemotePackageHashOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageHash,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string PackageHash { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public RequestWebRemotePackageHashOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestWebRemotePackageHashOperation));
|
||||||
|
_steps = ESteps.RequestPackageHash;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageHash)
|
||||||
|
{
|
||||||
|
if (_webTextRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, _packageVersion);
|
||||||
|
string url = GetWebRequestURL(fileName);
|
||||||
|
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _webTextRequestOp.Progress;
|
||||||
|
if (_webTextRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
PackageHash = _webTextRequestOp.Result;
|
||||||
|
if (string.IsNullOrEmpty(PackageHash))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Web remote package hash file content is empty !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webTextRequestOp.Error;
|
||||||
|
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(RequestWebRemotePackageHashOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetWebRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2a5bb0106a45e540a43a05b72a75bcd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,98 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class RequestWebRemotePackageVersionOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||||
|
private readonly bool _appendTimeTicks;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
internal RequestWebRemotePackageVersionOperation(DefaultWebRemoteFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_appendTimeTicks = appendTimeTicks;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestWebRemotePackageVersionOperation));
|
||||||
|
_steps = ESteps.RequestPackageVersion;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageVersion)
|
||||||
|
{
|
||||||
|
if (_webTextRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_fileSystem.PackageName);
|
||||||
|
string url = GetWebRequestURL(fileName);
|
||||||
|
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _webTextRequestOp.Progress;
|
||||||
|
if (_webTextRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
PackageVersion = _webTextRequestOp.Result;
|
||||||
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Web remote package version file content is empty !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webTextRequestOp.Error;
|
||||||
|
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(RequestWebRemotePackageVersionOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetWebRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
string url;
|
||||||
|
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
url = _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
url = _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
|
||||||
|
// 在URL末尾添加时间戳
|
||||||
|
if (_appendTimeTicks)
|
||||||
|
return $"{url}?{System.DateTime.UtcNow.Ticks}";
|
||||||
|
else
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a38597f546a46a429b24abd595c76e4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,7 +8,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Web文件系统
|
/// Web文件系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class DefaultWebFileSystem : IFileSystem
|
internal class DefaultWebServerFileSystem : IFileSystem
|
||||||
{
|
{
|
||||||
public class FileWrapper
|
public class FileWrapper
|
||||||
{
|
{
|
||||||
|
@ -59,24 +59,24 @@ namespace YooAsset
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public DefaultWebFileSystem()
|
public DefaultWebServerFileSystem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||||
{
|
{
|
||||||
var operation = new DWFSInitializeOperation(this);
|
var operation = new DWSFSInitializeOperation(this);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new DWFSLoadPackageManifestOperation(this, timeout);
|
var operation = new DWSFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new DWFSRequestPackageVersionOperation(this, timeout);
|
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
var operation = new DWFSLoadAssetBundleOperation(this, bundle);
|
var operation = new DWSFSLoadAssetBundleOperation(this, bundle);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_wrappers.ContainsKey(bundleGUID))
|
if (_wrappers.ContainsKey(bundleGUID))
|
||||||
{
|
{
|
||||||
YooLogger.Error($"{nameof(DefaultWebFileSystem)} has element : {bundleGUID}");
|
YooLogger.Error($"{nameof(DefaultWebServerFileSystem)} has element : {bundleGUID}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DWFSInitializeOperation : FSInitializeFileSystemOperation
|
internal class DWSFSInitializeOperation : FSInitializeFileSystemOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -10,12 +10,12 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private LoadWebCatalogFileOperation _loadCatalogFileOp;
|
private LoadWebServerCatalogFileOperation _loadCatalogFileOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
public DWFSInitializeOperation(DefaultWebFileSystem fileSystem)
|
public DWSFSInitializeOperation(DefaultWebServerFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace YooAsset
|
||||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_loadCatalogFileOp = new LoadWebCatalogFileOperation(_fileSystem);
|
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DWFSLoadAssetBundleOperation : FSLoadBundleOperation
|
internal class DWSFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -10,13 +10,13 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private readonly PackageBundle _bundle;
|
private readonly PackageBundle _bundle;
|
||||||
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal DWFSLoadAssetBundleOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle)
|
internal DWSFSLoadAssetBundleOperation(DefaultWebServerFileSystem fileSystem, PackageBundle bundle)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_bundle = bundle;
|
_bundle = bundle;
|
||||||
|
@ -38,7 +38,7 @@ namespace YooAsset
|
||||||
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
||||||
downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
||||||
downloadParam.FallbackURL = downloadParam.MainURL;
|
downloadParam.FallbackURL = downloadParam.MainURL;
|
||||||
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem, _bundle, downloadParam);
|
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadhanlderAssetBundleOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadhanlderAssetBundleOp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class DWSFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestWebPackageHash,
|
||||||
|
LoadWebPackageManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private RequestWebServerPackageHashOperation _requestWebPackageHashOp;
|
||||||
|
private LoadWebServerPackageManifestOperation _loadWebPackageManifestOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
public DWSFSLoadPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestWebPackageHash;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestWebPackageHash)
|
||||||
|
{
|
||||||
|
if (_requestWebPackageHashOp == null)
|
||||||
|
{
|
||||||
|
_requestWebPackageHashOp = new RequestWebServerPackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageHashOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_requestWebPackageHashOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_requestWebPackageHashOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadWebPackageManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _requestWebPackageHashOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadWebPackageManifest)
|
||||||
|
{
|
||||||
|
if (_loadWebPackageManifestOp == null)
|
||||||
|
{
|
||||||
|
string packageHash = _requestWebPackageHashOp.PackageHash;
|
||||||
|
_loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadWebPackageManifestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _loadWebPackageManifestOp.Progress;
|
||||||
|
if (_loadWebPackageManifestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_loadWebPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Manifest = _loadWebPackageManifestOp.Manifest;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _loadWebPackageManifestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DWFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
internal class DWSFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -10,13 +10,13 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private RequestWebPackageVersionOperation _requestWebPackageVersionOp;
|
private RequestWebServerPackageVersionOperation _requestWebPackageVersionOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal DWFSRequestPackageVersionOperation(DefaultWebFileSystem fileSystem, int timeout)
|
internal DWSFSRequestPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
|
@ -34,7 +34,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_requestWebPackageVersionOp == null)
|
if (_requestWebPackageVersionOp == null)
|
||||||
{
|
{
|
||||||
_requestWebPackageVersionOp = new RequestWebPackageVersionOperation(_fileSystem, _timeout);
|
_requestWebPackageVersionOp = new RequestWebServerPackageVersionOperation(_fileSystem, _timeout);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class LoadWebCatalogFileOperation : AsyncOperationBase
|
internal sealed class LoadWebServerCatalogFileOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -23,7 +23,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageVersion { private set; get; }
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
internal LoadWebCatalogFileOperation(DefaultWebFileSystem fileSystem)
|
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load web catalog file : {catalogFilePath}";
|
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Web catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageVersion = catalog.PackageVersion;
|
PackageVersion = catalog.PackageVersion;
|
||||||
foreach (var wrapper in catalog.Wrappers)
|
foreach (var wrapper in catalog.Wrappers)
|
||||||
{
|
{
|
||||||
var fileWrapper = new DefaultWebFileSystem.FileWrapper(wrapper.FileName);
|
var fileWrapper = new DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
||||||
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class LoadWebPackageManifestOperation : AsyncOperationBase
|
internal class LoadWebServerPackageManifestOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
private readonly string _packageHash;
|
private readonly string _packageHash;
|
||||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
|
@ -25,7 +25,7 @@ namespace YooAsset
|
||||||
public PackageManifest Manifest { private set; get; }
|
public PackageManifest Manifest { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal LoadWebPackageManifestOperation(DefaultWebFileSystem fileSystem, string packageVersion, string packageHash)
|
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_packageVersion = packageVersion;
|
_packageVersion = packageVersion;
|
||||||
|
@ -76,7 +76,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = "Failed to verify web package manifest file!";
|
Error = "Failed to verify web server package manifest file!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RequestWebPackageHashOperation : AsyncOperationBase
|
internal class RequestWebServerPackageHashOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||||
|
@ -22,7 +22,7 @@ namespace YooAsset
|
||||||
public string PackageHash { private set; get; }
|
public string PackageHash { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public RequestWebPackageHashOperation(DefaultWebFileSystem fileSystem, string packageVersion, int timeout)
|
public RequestWebServerPackageHashOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_packageVersion = packageVersion;
|
_packageVersion = packageVersion;
|
||||||
|
@ -58,7 +58,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Web package hash file content is empty !";
|
Error = $"Web server package hash file content is empty !";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RequestWebPackageVersionOperation : AsyncOperationBase
|
internal class RequestWebServerPackageVersionOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
@ -21,7 +21,7 @@ namespace YooAsset
|
||||||
public string PackageVersion { private set; get; }
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal RequestWebPackageVersionOperation(DefaultWebFileSystem fileSystem, int timeout)
|
internal RequestWebServerPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
|
@ -55,7 +55,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Web package version file content is empty !";
|
Error = $"Web server package version file content is empty !";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
|
@ -5,16 +5,16 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DownloadHandlerAssetBundleOperation : DefaultDownloadFileOperation
|
internal class DownloadHandlerAssetBundleOperation : DefaultDownloadFileOperation
|
||||||
{
|
{
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly bool _disableUnityWebCache;
|
||||||
private DownloadHandlerAssetBundle _downloadhandler;
|
private DownloadHandlerAssetBundle _downloadhandler;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
public AssetBundle Result { private set; get; }
|
public AssetBundle Result { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal DownloadHandlerAssetBundleOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadHandlerAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_disableUnityWebCache = disableUnityWebCache;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private DownloadHandlerAssetBundle CreateDownloadHandler()
|
private DownloadHandlerAssetBundle CreateDownloadHandler()
|
||||||
{
|
{
|
||||||
if (_fileSystem.DisableUnityWebCache)
|
if (_disableUnityWebCache)
|
||||||
{
|
{
|
||||||
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, 0);
|
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, 0);
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#if UNITY_2020_3_OR_NEWER
|
|
@ -165,16 +165,30 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建默认的Web文件系统参数
|
/// 创建默认的WebServer文件系统参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||||
public static FileSystemParameters CreateDefaultWebFileSystemParameters(bool disableUnityWebCache = false)
|
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultWebFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建默认的WebRemote文件系统参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||||
|
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||||
|
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||||
|
{
|
||||||
|
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||||
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||||
|
return fileSystemParams;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -206,7 +220,6 @@ namespace YooAsset
|
||||||
public class HostPlayModeParameters : InitializeParameters
|
public class HostPlayModeParameters : InitializeParameters
|
||||||
{
|
{
|
||||||
public FileSystemParameters BuildinFileSystemParameters;
|
public FileSystemParameters BuildinFileSystemParameters;
|
||||||
public FileSystemParameters DeliveryFileSystemParameters;
|
|
||||||
public FileSystemParameters CacheFileSystemParameters;
|
public FileSystemParameters CacheFileSystemParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +228,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WebPlayModeParameters : InitializeParameters
|
public class WebPlayModeParameters : InitializeParameters
|
||||||
{
|
{
|
||||||
public FileSystemParameters WebFileSystemParameters;
|
public FileSystemParameters WebServerFileSystemParameters;
|
||||||
|
public FileSystemParameters WebRemoteFileSystemParameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -171,9 +171,9 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CreateFileSystem,
|
CreateBuildinFileSystem,
|
||||||
InitBuildinFileSystem,
|
InitBuildinFileSystem,
|
||||||
InitDeliveryFileSystem,
|
CreateCacheFileSystem,
|
||||||
InitCacheFileSystem,
|
InitCacheFileSystem,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,6 @@ namespace YooAsset
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly HostPlayModeParameters _parameters;
|
private readonly HostPlayModeParameters _parameters;
|
||||||
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
|
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
|
||||||
private FSInitializeFileSystemOperation _initDeliveryFileSystemOp;
|
|
||||||
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
|
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
@ -192,14 +191,55 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CreateFileSystem;
|
_steps = ESteps.CreateBuildinFileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.CreateFileSystem)
|
if (_steps == ESteps.CreateBuildinFileSystem)
|
||||||
|
{
|
||||||
|
if (_parameters.BuildinFileSystemParameters == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CreateCacheFileSystem;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||||
|
if (_impl.BuildinFileSystem == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Failed to create buildin file system";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.InitBuildinFileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitBuildinFileSystem)
|
||||||
|
{
|
||||||
|
if (_initBuildinFileSystemOp == null)
|
||||||
|
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||||
|
|
||||||
|
Progress = _initBuildinFileSystemOp.Progress;
|
||||||
|
if (_initBuildinFileSystemOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CreateCacheFileSystem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _initBuildinFileSystemOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CreateCacheFileSystem)
|
||||||
{
|
{
|
||||||
if (_parameters.CacheFileSystemParameters == null)
|
if (_parameters.CacheFileSystemParameters == null)
|
||||||
{
|
{
|
||||||
|
@ -209,30 +249,6 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_parameters.BuildinFileSystemParameters != null)
|
|
||||||
{
|
|
||||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
|
||||||
if (_impl.BuildinFileSystem == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = "Failed to create buildin file system";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_parameters.DeliveryFileSystemParameters != null)
|
|
||||||
{
|
|
||||||
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
|
|
||||||
if (_impl.DeliveryFileSystem == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = "Failed to create delivery file system";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
||||||
if (_impl.CacheFileSystem == null)
|
if (_impl.CacheFileSystem == null)
|
||||||
{
|
{
|
||||||
|
@ -242,63 +258,7 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.InitBuildinFileSystem;
|
_steps = ESteps.InitCacheFileSystem;
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.InitBuildinFileSystem)
|
|
||||||
{
|
|
||||||
// 注意:内置文件系统可以为空
|
|
||||||
if (_impl.BuildinFileSystem == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.InitDeliveryFileSystem;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_initBuildinFileSystemOp == null)
|
|
||||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
|
||||||
|
|
||||||
Progress = _initBuildinFileSystemOp.Progress;
|
|
||||||
if (_initBuildinFileSystemOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.InitDeliveryFileSystem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _initBuildinFileSystemOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.InitDeliveryFileSystem)
|
|
||||||
{
|
|
||||||
// 注意:分发文件系统可以为空
|
|
||||||
if (_impl.DeliveryFileSystem == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.InitCacheFileSystem;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Progress = _initDeliveryFileSystemOp.Progress;
|
|
||||||
if (_initDeliveryFileSystemOp == null)
|
|
||||||
_initDeliveryFileSystemOp = _impl.DeliveryFileSystem.InitializeFileSystemAsync();
|
|
||||||
|
|
||||||
if (_initDeliveryFileSystemOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_initDeliveryFileSystemOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.InitCacheFileSystem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _initDeliveryFileSystemOp.Error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitCacheFileSystem)
|
if (_steps == ESteps.InitCacheFileSystem)
|
||||||
|
@ -333,14 +293,18 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CreateFileSystem,
|
CreateWebServerFileSystem,
|
||||||
InitWebFileSystem,
|
InitWebServerFileSystem,
|
||||||
|
CreateWebRemoteFileSystem,
|
||||||
|
InitWebRemoteFileSystem,
|
||||||
|
CheckResult,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly WebPlayModeImpl _impl;
|
private readonly WebPlayModeImpl _impl;
|
||||||
private readonly WebPlayModeParameters _parameters;
|
private readonly WebPlayModeParameters _parameters;
|
||||||
private FSInitializeFileSystemOperation _initWebFileSystemOp;
|
private FSInitializeFileSystemOperation _initWebServerFileSystemOp;
|
||||||
|
private FSInitializeFileSystemOperation _initWebRemoteFileSystemOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl, WebPlayModeParameters parameters)
|
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl, WebPlayModeParameters parameters)
|
||||||
|
@ -350,54 +314,107 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CreateFileSystem;
|
_steps = ESteps.CreateWebServerFileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.CreateFileSystem)
|
if (_steps == ESteps.CreateWebServerFileSystem)
|
||||||
{
|
{
|
||||||
if (_parameters.WebFileSystemParameters == null)
|
if (_parameters.WebServerFileSystemParameters == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = "Web file system parameters is null";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_impl.WebFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebFileSystemParameters);
|
_impl.WebServerFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebServerFileSystemParameters);
|
||||||
if (_impl.WebFileSystem == null)
|
if (_impl.WebServerFileSystem == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = "Failed to create web file system";
|
Error = "Failed to create web server file system";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.InitWebFileSystem;
|
_steps = ESteps.InitWebServerFileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitWebFileSystem)
|
if (_steps == ESteps.InitWebServerFileSystem)
|
||||||
{
|
{
|
||||||
if (_initWebFileSystemOp == null)
|
if (_initWebServerFileSystemOp == null)
|
||||||
_initWebFileSystemOp = _impl.WebFileSystem.InitializeFileSystemAsync();
|
_initWebServerFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||||
|
|
||||||
Progress = _initWebFileSystemOp.Progress;
|
Progress = _initWebServerFileSystemOp.Progress;
|
||||||
if (_initWebFileSystemOp.IsDone == false)
|
if (_initWebServerFileSystemOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_initWebFileSystemOp.Status == EOperationStatus.Succeed)
|
if (_initWebServerFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _initWebFileSystemOp.Error;
|
Error = _initWebServerFileSystemOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CreateWebRemoteFileSystem)
|
||||||
|
{
|
||||||
|
if (_parameters.WebRemoteFileSystemParameters == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_impl.WebRemoteFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebRemoteFileSystemParameters);
|
||||||
|
if (_impl.WebRemoteFileSystem == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Failed to create web remote file system";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.InitWebRemoteFileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitWebRemoteFileSystem)
|
||||||
|
{
|
||||||
|
if (_initWebRemoteFileSystemOp == null)
|
||||||
|
_initWebRemoteFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||||
|
|
||||||
|
Progress = _initWebRemoteFileSystemOp.Progress;
|
||||||
|
if (_initWebRemoteFileSystemOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_initWebRemoteFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _initWebRemoteFileSystemOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckResult)
|
||||||
|
{
|
||||||
|
if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Not found any file system !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ namespace YooAsset
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ namespace YooAsset
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ namespace YooAsset
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ namespace YooAsset
|
||||||
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
|
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
|
||||||
assetInfos.Add(assetInfo);
|
assetInfos.Add(assetInfo);
|
||||||
|
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ namespace YooAsset
|
||||||
assetInfos.Add(assetInfo);
|
assetInfos.Add(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
public readonly string PackageName;
|
public readonly string PackageName;
|
||||||
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
|
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
|
||||||
public IFileSystem DeliveryFileSystem { set; get; } //可以为空!
|
|
||||||
public IFileSystem CacheFileSystem { set; get; }
|
public IFileSystem CacheFileSystem { set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,9 +34,6 @@ namespace YooAsset
|
||||||
if (BuildinFileSystem != null)
|
if (BuildinFileSystem != null)
|
||||||
BuildinFileSystem.OnUpdate();
|
BuildinFileSystem.OnUpdate();
|
||||||
|
|
||||||
if (DeliveryFileSystem != null)
|
|
||||||
DeliveryFileSystem.OnUpdate();
|
|
||||||
|
|
||||||
if (CacheFileSystem != null)
|
if (CacheFileSystem != null)
|
||||||
CacheFileSystem.OnUpdate();
|
CacheFileSystem.OnUpdate();
|
||||||
}
|
}
|
||||||
|
@ -63,50 +59,50 @@ namespace YooAsset
|
||||||
|
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, CacheFileSystem);
|
||||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -123,11 +119,6 @@ namespace YooAsset
|
||||||
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
if (DeliveryFileSystem != null && DeliveryFileSystem.Belong(packageBundle))
|
|
||||||
{
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(DeliveryFileSystem, packageBundle);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
if (CacheFileSystem.Belong(packageBundle))
|
if (CacheFileSystem.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(CacheFileSystem, packageBundle);
|
BundleInfo bundleInfo = new BundleInfo(CacheFileSystem, packageBundle);
|
||||||
|
|
|
@ -7,7 +7,8 @@ namespace YooAsset
|
||||||
internal class WebPlayModeImpl : IPlayMode, IBundleQuery
|
internal class WebPlayModeImpl : IPlayMode, IBundleQuery
|
||||||
{
|
{
|
||||||
public readonly string PackageName;
|
public readonly string PackageName;
|
||||||
public IFileSystem WebFileSystem { set; get; }
|
public IFileSystem WebServerFileSystem { set; get; } //可以为空!
|
||||||
|
public IFileSystem WebRemoteFileSystem { set; get; } //可以为空!
|
||||||
|
|
||||||
|
|
||||||
public WebPlayModeImpl(string packageName)
|
public WebPlayModeImpl(string packageName)
|
||||||
|
@ -30,21 +31,42 @@ namespace YooAsset
|
||||||
|
|
||||||
void IPlayMode.UpdatePlayMode()
|
void IPlayMode.UpdatePlayMode()
|
||||||
{
|
{
|
||||||
if (WebFileSystem != null)
|
if (WebServerFileSystem != null)
|
||||||
WebFileSystem.OnUpdate();
|
WebServerFileSystem.OnUpdate();
|
||||||
|
|
||||||
|
if (WebRemoteFileSystem != null)
|
||||||
|
WebRemoteFileSystem.OnUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new RequestPackageVersionImplOperation(WebFileSystem, appendTimeTicks, timeout);
|
if (WebRemoteFileSystem != null)
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
{
|
||||||
return operation;
|
var operation = new RequestPackageVersionImplOperation(WebRemoteFileSystem, appendTimeTicks, timeout);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var operation = new RequestPackageVersionImplOperation(WebServerFileSystem, appendTimeTicks, timeout);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new UpdatePackageManifestImplOperation(this, WebFileSystem, packageVersion, timeout);;
|
if (WebRemoteFileSystem != null)
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
{
|
||||||
return operation;
|
var operation = new UpdatePackageManifestImplOperation(this, WebRemoteFileSystem, packageVersion, timeout); ;
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var operation = new UpdatePackageManifestImplOperation(this, WebServerFileSystem, packageVersion, timeout); ;
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
|
@ -55,50 +77,50 @@ namespace YooAsset
|
||||||
|
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, WebFileSystem, null, null);
|
var operation = new ClearAllBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebFileSystem, null, null);
|
var operation = new ClearUnusedBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, WebFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, WebFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, WebFileSystem);
|
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, WebFileSystem);
|
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, WebFileSystem);
|
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, WebFileSystem);
|
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, WebServerFileSystem, WebRemoteFileSystem);
|
||||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -110,9 +132,15 @@ namespace YooAsset
|
||||||
if (packageBundle == null)
|
if (packageBundle == null)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (WebFileSystem.Belong(packageBundle))
|
if (WebServerFileSystem != null && WebServerFileSystem.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(WebFileSystem, packageBundle);
|
BundleInfo bundleInfo = new BundleInfo(WebServerFileSystem, packageBundle);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WebRemoteFileSystem != null && WebRemoteFileSystem.Belong(packageBundle))
|
||||||
|
{
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(WebRemoteFileSystem, packageBundle);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,10 +181,20 @@ namespace YooAsset
|
||||||
if (_playMode == EPlayMode.WebPlayMode)
|
if (_playMode == EPlayMode.WebPlayMode)
|
||||||
{
|
{
|
||||||
var webPlayModeParams = parameters as WebPlayModeParameters;
|
var webPlayModeParams = parameters as WebPlayModeParameters;
|
||||||
var fileSystemClassName = webPlayModeParams.WebFileSystemParameters.FileSystemClass;
|
if (webPlayModeParams.WebServerFileSystemParameters != null)
|
||||||
if (fileSystemClassName == typeof(DefaultCacheFileSystem).FullName
|
{
|
||||||
|| fileSystemClassName == typeof(DefaultBuildinFileSystem).FullName)
|
var fileSystemClassName = webPlayModeParams.WebServerFileSystemParameters.FileSystemClass;
|
||||||
throw new Exception($"{fileSystemClassName} not support {nameof(EPlayMode.WebPlayMode)}");
|
if (fileSystemClassName == typeof(DefaultCacheFileSystem).FullName
|
||||||
|
|| fileSystemClassName == typeof(DefaultBuildinFileSystem).FullName)
|
||||||
|
throw new Exception($"{fileSystemClassName} not support {nameof(EPlayMode.WebPlayMode)}");
|
||||||
|
}
|
||||||
|
if (webPlayModeParams.WebRemoteFileSystemParameters != null)
|
||||||
|
{
|
||||||
|
var fileSystemClassName = webPlayModeParams.WebRemoteFileSystemParameters.FileSystemClass;
|
||||||
|
if (fileSystemClassName == typeof(DefaultCacheFileSystem).FullName
|
||||||
|
|| fileSystemClassName == typeof(DefaultBuildinFileSystem).FullName)
|
||||||
|
throw new Exception($"{fileSystemClassName} not support {nameof(EPlayMode.WebPlayMode)}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void InitializeOperation_Completed(AsyncOperationBase op)
|
private void InitializeOperation_Completed(AsyncOperationBase op)
|
||||||
|
|
|
@ -92,7 +92,7 @@ internal class FsmInitializePackage : IStateNode
|
||||||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||||
createParameters.WebFileSystemParameters = WechatFileSystemCreater.CreateWechatFileSystemParameters(remoteServices);
|
createParameters.WebFileSystemParameters = WechatFileSystemCreater.CreateWechatFileSystemParameters(remoteServices);
|
||||||
#else
|
#else
|
||||||
createParameters.WebFileSystemParameters = FileSystemParameters.CreateDefaultWebFileSystemParameters();
|
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
||||||
#endif
|
#endif
|
||||||
initializationOperation = package.InitializeAsync(createParameters);
|
initializationOperation = package.InitializeAsync(createParameters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue