mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
TEngine 6
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSInitializeOperation : FSInitializeFileSystemOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadCatalogFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private LoadWebServerCatalogFileOperation _loadCatalogFileOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DWSFSInitializeOperation(DefaultWebServerFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadCatalogFile;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadCatalogFile)
|
||||
{
|
||||
if (_loadCatalogFileOp == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.FileRoot;
|
||||
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
if (result == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Create package catalog file failed ! See the detail error in console !";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
|
||||
_loadCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadCatalogFileOp);
|
||||
}
|
||||
|
||||
_loadCatalogFileOp.UpdateOperation();
|
||||
if (_loadCatalogFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadCatalogFileOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c7cf2dca805b0b4d91cb5e0782dcb0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,98 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
DownloadAssetBundle,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private DownloadAssetBundleOperation _downloadAssetBundleOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWSFSLoadAssetBundleOperation(DefaultWebServerFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.DownloadAssetBundle;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.DownloadAssetBundle)
|
||||
{
|
||||
if (_downloadAssetBundleOp == null)
|
||||
{
|
||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
||||
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
||||
downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
||||
downloadParam.FallbackURL = downloadParam.MainURL;
|
||||
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
|
||||
_downloadAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_downloadAssetBundleOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
||||
_downloadAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_downloadAssetBundleOp);
|
||||
}
|
||||
}
|
||||
|
||||
_downloadAssetBundleOp.UpdateOperation();
|
||||
DownloadProgress = _downloadAssetBundleOp.DownloadProgress;
|
||||
DownloadedBytes = _downloadAssetBundleOp.DownloadedBytes;
|
||||
Progress = _downloadAssetBundleOp.Progress;
|
||||
if (_downloadAssetBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_downloadAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
var assetBundle = _downloadAssetBundleOp.Result;
|
||||
if (assetBundle == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(DownloadAssetBundleOperation)} loaded asset bundle is null !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = new AssetBundleResult(_fileSystem, _bundle, assetBundle, null);
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloadAssetBundleOp.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a50dacdf7a3ad7c40a4195126425bbec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,92 @@
|
||||
|
||||
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 InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestWebPackageHash;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestWebPackageHash)
|
||||
{
|
||||
if (_requestWebPackageHashOp == null)
|
||||
{
|
||||
_requestWebPackageHashOp = new RequestWebServerPackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||
_requestWebPackageHashOp.StartOperation();
|
||||
AddChildOperation(_requestWebPackageHashOp);
|
||||
}
|
||||
|
||||
_requestWebPackageHashOp.UpdateOperation();
|
||||
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);
|
||||
_loadWebPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadWebPackageManifestOp);
|
||||
}
|
||||
|
||||
_loadWebPackageManifestOp.UpdateOperation();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d0f8063cfabb5d40b364f162ce49fc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,62 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private RequestWebServerPackageVersionOperation _requestWebPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWSFSRequestPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_requestWebPackageVersionOp == null)
|
||||
{
|
||||
_requestWebPackageVersionOp = new RequestWebServerPackageVersionOperation(_fileSystem, _timeout);
|
||||
_requestWebPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestWebPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestWebPackageVersionOp.UpdateOperation();
|
||||
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: 212a79e362fe6234c81fa79c3924dd20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e91f62e8fc7c1f4592681b7881ad925
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class LoadWebServerCatalogFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadCatalog,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 内置清单版本
|
||||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadCatalog;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadCatalog)
|
||||
{
|
||||
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
||||
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
||||
if (catalog == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
if (catalog.PackageName != _fileSystem.PackageName)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||
return;
|
||||
}
|
||||
|
||||
PackageVersion = catalog.PackageVersion;
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c34c01e10454c842819e066eef488cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,118 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadWebServerPackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestFileData,
|
||||
VerifyFileData,
|
||||
LoadManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly string _packageHash;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹清单
|
||||
/// </summary>
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_packageHash = packageHash;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestFileData;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestFileData)
|
||||
{
|
||||
if (_webDataRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetWebPackageManifestFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||
_webDataRequestOp.StartOperation();
|
||||
AddChildOperation(_webDataRequestOp);
|
||||
}
|
||||
|
||||
_webDataRequestOp.UpdateOperation();
|
||||
if (_webDataRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.VerifyFileData;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webDataRequestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify web server package manifest file!";
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadManifest)
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
_deserializer.UpdateOperation();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override string InternalGetDesc()
|
||||
{
|
||||
return $"PackageVersion : {_packageVersion} PackageHash : {_packageHash}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04a60c61990d93b4cb934ab1901a44f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,80 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebServerPackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageHash,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹哈希值
|
||||
/// </summary>
|
||||
public string PackageHash { private set; get; }
|
||||
|
||||
|
||||
public RequestWebServerPackageHashOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageHash;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageHash)
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetWebPackageHashFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
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 server package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webTextRequestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ead93dc6c4d5ed942b209ec2202087dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,77 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebServerPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestWebServerPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetWebPackageVersionFilePath();
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
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 server package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webTextRequestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfa0e562b63f31141bbf04d4d5336d87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user