feat : web play mode support remote services
WebPlayMode支持跨域加载。
This commit is contained in:
@@ -7,7 +7,8 @@ namespace YooAsset
|
||||
internal class WebPlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem WebFileSystem { set; get; }
|
||||
public IFileSystem WebServerFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem WebRemoteFileSystem { set; get; } //可以为空!
|
||||
|
||||
|
||||
public WebPlayModeImpl(string packageName)
|
||||
@@ -30,21 +31,42 @@ namespace YooAsset
|
||||
|
||||
void IPlayMode.UpdatePlayMode()
|
||||
{
|
||||
if (WebFileSystem != null)
|
||||
WebFileSystem.OnUpdate();
|
||||
if (WebServerFileSystem != null)
|
||||
WebServerFileSystem.OnUpdate();
|
||||
|
||||
if (WebRemoteFileSystem != null)
|
||||
WebRemoteFileSystem.OnUpdate();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(WebFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebFileSystem, packageVersion, timeout);;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -55,50 +77,50 @@ namespace YooAsset
|
||||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, WebFileSystem, null, null);
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebFileSystem, null, null);
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
@@ -110,9 +132,15 @@ namespace YooAsset
|
||||
if (packageBundle == null)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user