mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-26 02:30:18 +00:00
Compare commits
29 Commits
2.3.14
...
0f73dc3047
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f73dc3047 | ||
|
|
a85e49c22a | ||
|
|
6b291de922 | ||
|
|
a4b1300195 | ||
|
|
6f34951a74 | ||
|
|
c798250258 | ||
|
|
6fc82bb55a | ||
|
|
c22cf5ffeb | ||
|
|
36bc24f9fd | ||
|
|
addb0ecdfe | ||
|
|
89e23e0df8 | ||
|
|
e2f582834e | ||
|
|
d2c2844f61 | ||
|
|
1de64278ad | ||
|
|
227f2332a9 | ||
|
|
131614687c | ||
|
|
b8ec902f60 | ||
|
|
eb3e29b6ad | ||
|
|
11ed9d391a | ||
|
|
9cd50bc7f3 | ||
|
|
e92505ba88 | ||
|
|
06a670730c | ||
|
|
ccd21e56cb | ||
|
|
522bcc529a | ||
|
|
2254ac9f5e | ||
|
|
956b3db71d | ||
|
|
fb56959c61 | ||
|
|
b9b9f4e37d | ||
|
|
c050d6d172 |
@@ -294,6 +294,11 @@ namespace YooAsset.Editor
|
|||||||
_scannerListView.itemsSource = filterItems;
|
_scannerListView.itemsSource = filterItems;
|
||||||
_scannerListView.Rebuild();
|
_scannerListView.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_lastModifyScannerIndex >= 0 && _lastModifyScannerIndex < _scannerListView.itemsSource.Count)
|
||||||
|
{
|
||||||
|
_scannerListView.selectedIndex = _lastModifyScannerIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private List<AssetArtScanner> FilterScanners()
|
private List<AssetArtScanner> FilterScanners()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ namespace YooAsset.Editor
|
|||||||
foreach (var classType in viewerClassTypes)
|
foreach (var classType in viewerClassTypes)
|
||||||
{
|
{
|
||||||
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
||||||
|
if (buildPipelineAttribute == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"The class {classType.FullName} need attribute {nameof(BuildPipelineAttribute)}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string pipelineName = buildPipelineAttribute.PipelineName;
|
string pipelineName = buildPipelineAttribute.PipelineName;
|
||||||
if (_viewClassDic.ContainsKey(pipelineName))
|
if (_viewClassDic.ContainsKey(pipelineName))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageFileCRC { set; get; }
|
public uint PackageFileCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace YooAsset.Editor
|
|||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = ManifestDefine.FileVersion;
|
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
|
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace YooAsset.Editor
|
|||||||
// 收集器配置
|
// 收集器配置
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
|
buildReport.Summary.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
|||||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从文件头里剥离Unity版本信息
|
||||||
|
/// </summary>
|
||||||
|
public bool StripUnityVersion = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -41,6 +46,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
if (ClearBuildCacheFiles)
|
if (ClearBuildCacheFiles)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
|
if (StripUnityVersion)
|
||||||
|
opt |= BuildAssetBundleOptions.AssetBundleStripUnityVersion; //Removes the Unity Version number in the Archive File & Serialized File headers
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
if (IgnoreTypeTreeChanges)
|
if (IgnoreTypeTreeChanges)
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
return "00000000"; //8位
|
return 0;
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
|||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从AssetBundle文件头里剥离Unity版本信息
|
/// 从文件头里剥离Unity版本信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool StripUnityVersion = false;
|
public bool StripUnityVersion = false;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
public bool DisableWriteTypeTree = false;
|
public bool DisableWriteTypeTree = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略类型树变化
|
/// 忽略类型树变化(无效参数)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
@@ -76,10 +76,9 @@ namespace YooAsset.Editor
|
|||||||
throw new System.NotImplementedException(CompressOption.ToString());
|
throw new System.NotImplementedException(CompressOption.ToString());
|
||||||
|
|
||||||
if (StripUnityVersion)
|
if (StripUnityVersion)
|
||||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.StripUnityVersion;
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.StripUnityVersion; // Build Flag to indicate the Unity Version should not be written to the serialized file.
|
||||||
|
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree; //Do not include type information within the built content.
|
||||||
|
|
||||||
buildParams.UseCache = true;
|
buildParams.UseCache = true;
|
||||||
buildParams.CacheServerHost = CacheServerHost;
|
buildParams.CacheServerHost = CacheServerHost;
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ namespace YooAsset.Editor
|
|||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||||
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
|
||||||
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
@@ -122,10 +121,10 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
|
buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
|
||||||
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
|
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
|
||||||
|
buildParameters.BuiltinShadersBundleName = GetBuiltinShaderBundleName();
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
@@ -143,6 +142,16 @@ namespace YooAsset.Editor
|
|||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mono脚本的资源包名称
|
||||||
|
/// </summary>
|
||||||
|
protected string GetMonoScriptsBundleName()
|
||||||
|
{
|
||||||
|
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||||
|
var packRuleResult = DefaultPackRule.CreateMonosPackRuleResult();
|
||||||
|
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -139,13 +139,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
// 注意:模拟构建模式下只收集主资源
|
|
||||||
if (command.SimulateBuild)
|
|
||||||
{
|
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
|
||||||
return new List<CollectAssetInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
|
|
||||||
// 收集打包资源路径
|
// 收集打包资源路径
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "v2.1";
|
public const string ConfigVersion = "v2025.8.28";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
@@ -23,6 +23,7 @@ namespace YooAsset.Editor
|
|||||||
public const string XmlPackageName = "PackageName";
|
public const string XmlPackageName = "PackageName";
|
||||||
public const string XmlPackageDesc = "PackageDesc";
|
public const string XmlPackageDesc = "PackageDesc";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
|
public const string XmlSupportExtensionless = "SupportExtensionless";
|
||||||
public const string XmlLocationToLower = "LocationToLower";
|
public const string XmlLocationToLower = "LocationToLower";
|
||||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||||
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
||||||
@@ -99,6 +100,7 @@ namespace YooAsset.Editor
|
|||||||
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
||||||
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
||||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
|
package.SupportExtensionless = packageElement.GetAttribute(XmlSupportExtensionless) == "True" ? true : false;
|
||||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||||
package.IgnoreRuleName = packageElement.GetAttribute(XmlIgnoreRuleName);
|
package.IgnoreRuleName = packageElement.GetAttribute(XmlIgnoreRuleName);
|
||||||
@@ -211,6 +213,7 @@ namespace YooAsset.Editor
|
|||||||
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
||||||
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
||||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||||
|
packageElement.SetAttribute(XmlSupportExtensionless, package.SupportExtensionless.ToString());
|
||||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||||
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
||||||
@@ -275,6 +278,23 @@ namespace YooAsset.Editor
|
|||||||
return UpdateXmlConfig(xmlDoc);
|
return UpdateXmlConfig(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v2.1 -> v2025.8.28
|
||||||
|
if (configVersion == "v2.1")
|
||||||
|
{
|
||||||
|
// 读取包裹配置
|
||||||
|
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||||
|
foreach (var packageNode in packageNodeList)
|
||||||
|
{
|
||||||
|
XmlElement packageElement = packageNode as XmlElement;
|
||||||
|
if (packageElement.HasAttribute(XmlSupportExtensionless) == false)
|
||||||
|
packageElement.SetAttribute(XmlSupportExtensionless, "True");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新版本
|
||||||
|
root.SetAttribute(XmlVersion, "v2025.8.28");
|
||||||
|
return UpdateXmlConfig(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持无后缀名的资源定位地址
|
||||||
|
/// </summary>
|
||||||
|
public bool SupportExtensionless = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ namespace YooAsset.Editor
|
|||||||
command.UniqueBundleName = UniqueBundleName;
|
command.UniqueBundleName = UniqueBundleName;
|
||||||
command.UseAssetDependencyDB = useAssetDependencyDB;
|
command.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
command.EnableAddressable = package.EnableAddressable;
|
command.EnableAddressable = package.EnableAddressable;
|
||||||
|
command.SupportExtensionless = package.SupportExtensionless;
|
||||||
command.LocationToLower = package.LocationToLower;
|
command.LocationToLower = package.LocationToLower;
|
||||||
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
||||||
command.AutoCollectShaders = package.AutoCollectShaders;
|
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private VisualElement _setting2Container;
|
private VisualElement _setting2Container;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
private Toggle _supportExtensionlessToogle;
|
||||||
private Toggle _locationToLowerToogle;
|
private Toggle _locationToLowerToogle;
|
||||||
private Toggle _includeAssetGUIDToogle;
|
private Toggle _includeAssetGUIDToogle;
|
||||||
private Toggle _autoCollectShadersToogle;
|
private Toggle _autoCollectShadersToogle;
|
||||||
@@ -131,6 +132,17 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_supportExtensionlessToogle = root.Q<Toggle>("SupportExtensionless");
|
||||||
|
_supportExtensionlessToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
|
if (selectPackage != null)
|
||||||
|
{
|
||||||
|
selectPackage.SupportExtensionless = evt.newValue;
|
||||||
|
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
_locationToLowerToogle = root.Q<Toggle>("LocationToLower");
|
_locationToLowerToogle = root.Q<Toggle>("LocationToLower");
|
||||||
_locationToLowerToogle.RegisterValueChangedCallback(evt =>
|
_locationToLowerToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
@@ -487,6 +499,7 @@ namespace YooAsset.Editor
|
|||||||
_packageSettingsButton.SetEnabled(true);
|
_packageSettingsButton.SetEnabled(true);
|
||||||
_packageSettingsButton.text = $"{packageSettingName} ({selectPackage.PackageName})";
|
_packageSettingsButton.text = $"{packageSettingName} ({selectPackage.PackageName})";
|
||||||
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
||||||
|
_supportExtensionlessToogle.SetValueWithoutNotify(selectPackage.SupportExtensionless);
|
||||||
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
||||||
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
||||||
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
||||||
@@ -831,7 +844,7 @@ namespace YooAsset.Editor
|
|||||||
var foldout = new Foldout();
|
var foldout = new Foldout();
|
||||||
foldout.name = "Foldout1";
|
foldout.name = "Foldout1";
|
||||||
foldout.value = false;
|
foldout.value = false;
|
||||||
foldout.text = "Main Assets";
|
foldout.text = "Assets";
|
||||||
elementFoldout.Add(foldout);
|
elementFoldout.Add(foldout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -864,11 +877,9 @@ namespace YooAsset.Editor
|
|||||||
var foldout = element.Q<Foldout>("Foldout1");
|
var foldout = element.Q<Foldout>("Foldout1");
|
||||||
foldout.RegisterValueChangedCallback(evt =>
|
foldout.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
if (evt.newValue)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
else
|
|
||||||
foldout.Clear();
|
|
||||||
});
|
});
|
||||||
|
RefreshFoldoutName(foldout, collector.CollectorType);
|
||||||
|
|
||||||
// Remove Button
|
// Remove Button
|
||||||
var removeBtn = element.Q<Button>("Button1");
|
var removeBtn = element.Q<Button>("Button1");
|
||||||
@@ -885,10 +896,7 @@ namespace YooAsset.Editor
|
|||||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
{
|
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
UIElementsTools.RefreshObjectFieldShowPath(objectField1);
|
UIElementsTools.RefreshObjectFieldShowPath(objectField1);
|
||||||
|
|
||||||
@@ -899,10 +907,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(evt.newValue);
|
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(evt.newValue);
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
{
|
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (collector.CollectorType == ECollectorType.MainAssetCollector)
|
if (collector.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
textTags.SetEnabled(true);
|
textTags.SetEnabled(true);
|
||||||
@@ -921,10 +926,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.AddressRuleName = evt.newValue.ClassName;
|
collector.AddressRuleName = evt.newValue.ClassName;
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
{
|
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,10 +939,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.PackRuleName = evt.newValue.ClassName;
|
collector.PackRuleName = evt.newValue.ClassName;
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
{
|
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter Rule
|
// Filter Rule
|
||||||
@@ -952,10 +951,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.FilterRuleName = evt.newValue.ClassName;
|
collector.FilterRuleName = evt.newValue.ClassName;
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||||
{
|
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// UserData
|
// UserData
|
||||||
@@ -976,61 +972,101 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
private void RefreshFoldoutName(Foldout foldout, ECollectorType collectorType, int elementNumber = -1)
|
||||||
{
|
{
|
||||||
|
if (collectorType == ECollectorType.MainAssetCollector)
|
||||||
|
{
|
||||||
|
if (elementNumber >= 0)
|
||||||
|
foldout.text = $"Main Assets ({elementNumber})";
|
||||||
|
else
|
||||||
|
foldout.text = $"Main Assets";
|
||||||
|
}
|
||||||
|
else if (collectorType == ECollectorType.StaticAssetCollector)
|
||||||
|
{
|
||||||
|
if (elementNumber >= 0)
|
||||||
|
foldout.text = $"Static Assets ({elementNumber})";
|
||||||
|
else
|
||||||
|
foldout.text = $"Static Assets";
|
||||||
|
}
|
||||||
|
else if (collectorType == ECollectorType.DependAssetCollector)
|
||||||
|
{
|
||||||
|
if (elementNumber >= 0)
|
||||||
|
foldout.text = $"Depend Assets ({elementNumber})";
|
||||||
|
else
|
||||||
|
foldout.text = $"Depend Assets";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(collectorType.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void RefreshFoldoutContent(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
|
{
|
||||||
|
RefreshFoldoutName(foldout, collector.CollectorType);
|
||||||
|
|
||||||
|
// 折叠栏不可见
|
||||||
|
if (foldout.value == false)
|
||||||
|
{
|
||||||
|
foldout.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 清空旧元素
|
// 清空旧元素
|
||||||
foldout.Clear();
|
foldout.Clear();
|
||||||
|
|
||||||
|
// 检测配置是否有效
|
||||||
if (collector.IsValid() == false)
|
if (collector.IsValid() == false)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collector.CollectorType == ECollectorType.MainAssetCollector || collector.CollectorType == ECollectorType.StaticAssetCollector)
|
List<CollectAssetInfo> collectAssetInfos = null;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<CollectAssetInfo> collectAssetInfos = null;
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||||
|
string packageName = _packageNameTxt.value;
|
||||||
|
var command = new CollectCommand(packageName, ignoreRule);
|
||||||
|
command.SimulateBuild = true;
|
||||||
|
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||||
|
command.EnableAddressable = _enableAddressableToogle.value;
|
||||||
|
command.SupportExtensionless = _supportExtensionlessToogle.value;
|
||||||
|
command.LocationToLower = _locationToLowerToogle.value;
|
||||||
|
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
||||||
|
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
||||||
|
|
||||||
try
|
collector.CheckConfigError();
|
||||||
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectAssetInfos != null)
|
||||||
|
{
|
||||||
|
bool showAdress = false;
|
||||||
|
if (_enableAddressableToogle.value && collector.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
|
showAdress = true;
|
||||||
|
|
||||||
|
RefreshFoldoutName(foldout, collector.CollectorType, collectAssetInfos.Count);
|
||||||
|
foreach (var collectAsset in collectAssetInfos)
|
||||||
{
|
{
|
||||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
VisualElement elementRow = new VisualElement();
|
||||||
string packageName = _packageNameTxt.value;
|
elementRow.style.flexDirection = FlexDirection.Row;
|
||||||
var command = new CollectCommand(packageName, ignoreRule);
|
foldout.Add(elementRow);
|
||||||
command.SimulateBuild = true;
|
|
||||||
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
|
||||||
command.UseAssetDependencyDB = true;
|
|
||||||
command.EnableAddressable = _enableAddressableToogle.value;
|
|
||||||
command.LocationToLower = _locationToLowerToogle.value;
|
|
||||||
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
|
||||||
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
|
||||||
|
|
||||||
collector.CheckConfigError();
|
string showInfo = collectAsset.AssetInfo.AssetPath;
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
if (showAdress)
|
||||||
}
|
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (collectAssetInfos != null)
|
var label = new Label();
|
||||||
{
|
label.text = showInfo;
|
||||||
foreach (var collectAsset in collectAssetInfos)
|
label.style.width = 300;
|
||||||
{
|
label.style.marginLeft = 0;
|
||||||
VisualElement elementRow = new VisualElement();
|
label.style.flexGrow = 1;
|
||||||
elementRow.style.flexDirection = FlexDirection.Row;
|
elementRow.Add(label);
|
||||||
foldout.Add(elementRow);
|
|
||||||
|
|
||||||
string showInfo = collectAsset.AssetInfo.AssetPath;
|
|
||||||
if (_enableAddressableToogle.value)
|
|
||||||
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
|
||||||
|
|
||||||
var label = new Label();
|
|
||||||
label.text = showInfo;
|
|
||||||
label.style.width = 300;
|
|
||||||
label.style.marginLeft = 0;
|
|
||||||
label.style.flexGrow = 1;
|
|
||||||
elementRow.Add(label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
||||||
<ui:VisualElement name="PublicContainer2">
|
<ui:VisualElement name="PublicContainer2">
|
||||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
<ui:Toggle label="Support Extensionless" name="SupportExtensionless" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable { set; get; }
|
public bool EnableAddressable { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持无后缀名的资源定位地址
|
||||||
|
/// </summary>
|
||||||
|
public bool SupportExtensionless { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,16 +17,25 @@ namespace YooAsset.Editor
|
|||||||
public const string RawFileExtension = "rawfile";
|
public const string RawFileExtension = "rawfile";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unity着色器资源包名称
|
/// 默认的Unity着色器资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ShadersBundleName = "unityshaders";
|
public const string ShadersBundleName = "unityshaders";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认的Unity脚本资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public const string MonosBundleName = "unitymonos";
|
||||||
|
|
||||||
public static PackRuleResult CreateShadersPackRuleResult()
|
public static PackRuleResult CreateShadersPackRuleResult()
|
||||||
{
|
{
|
||||||
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static PackRuleResult CreateMonosPackRuleResult()
|
||||||
|
{
|
||||||
|
PackRuleResult result = new PackRuleResult(MonosBundleName, AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileCRC;
|
public uint FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace YooAsset.Editor
|
|||||||
// 收集器配置
|
// 收集器配置
|
||||||
public bool UniqueBundleName;
|
public bool UniqueBundleName;
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
public bool SupportExtensionless;
|
||||||
public bool LocationToLower;
|
public bool LocationToLower;
|
||||||
public bool IncludeAssetGUID;
|
public bool IncludeAssetGUID;
|
||||||
public bool AutoCollectShaders;
|
public bool AutoCollectShaders;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ namespace YooAsset.Editor
|
|||||||
BindListViewHeader("Collect Settings");
|
BindListViewHeader("Collect Settings");
|
||||||
BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
|
BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
|
||||||
BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
|
BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
|
||||||
|
BindListViewItem("Support Extensionless", $"{buildReport.Summary.SupportExtensionless}");
|
||||||
BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
|
BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
|
||||||
BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
|
BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
|
||||||
BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
|
BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
|
||||||
|
|||||||
@@ -37,13 +37,17 @@ namespace YooAsset
|
|||||||
string url;
|
string url;
|
||||||
|
|
||||||
// 获取对应平台的URL地址
|
// 获取对应平台的URL地址
|
||||||
|
// 说明:苹果不同设备上操作系统不同。
|
||||||
|
// 说明:iPhone和iPod对应的是iOS系统。
|
||||||
|
// 说明:iPad对应的是iPadOS系统。
|
||||||
|
// 说明:AppleTV对应的是tvOS系统。
|
||||||
#if UNITY_EDITOR_OSX
|
#if UNITY_EDITOR_OSX
|
||||||
url = StringUtility.Format("file://{0}", path);
|
url = StringUtility.Format("file://{0}", path);
|
||||||
#elif UNITY_EDITOR
|
#elif UNITY_EDITOR_WIN
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
#elif UNITY_WEBGL
|
#elif UNITY_WEBGL
|
||||||
url = path;
|
url = path;
|
||||||
#elif UNITY_IPHONE
|
#elif UNITY_IOS || UNITY_IPHONE
|
||||||
url = StringUtility.Format("file://{0}", path);
|
url = StringUtility.Format("file://{0}", path);
|
||||||
#elif UNITY_ANDROID
|
#elif UNITY_ANDROID
|
||||||
if (path.StartsWith("jar:file://"))
|
if (path.StartsWith("jar:file://"))
|
||||||
@@ -65,12 +69,17 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
url = StringUtility.Format("file://{0}", path);
|
url = StringUtility.Format("file://{0}", path);
|
||||||
}
|
}
|
||||||
#elif UNITY_STANDALONE_OSX
|
|
||||||
url = new System.Uri(path).ToString();
|
#elif UNITY_WSA
|
||||||
#elif UNITY_STANDALONE || UNITY_WSA
|
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
#elif UNITY_TVOS
|
#elif UNITY_TVOS
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
|
#elif UNITY_STANDALONE_OSX
|
||||||
|
url = new System.Uri(path).ToString();
|
||||||
|
#elif UNITY_STANDALONE_WIN
|
||||||
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
|
#elif UNITY_STANDALONE_LINUX
|
||||||
|
url = StringUtility.Format("file:///root/{0}", path);
|
||||||
#else
|
#else
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,15 +53,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region 自定义参数
|
#region 自定义参数
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:初始化的时候缓存文件校验级别
|
/// 自定义参数:初始化的时候缓存文件校验级别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:覆盖安装缓存清理模式
|
/// 自定义参数:初始化的时候缓存文件校验最大并发数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
public int FileVerifyMaxConcurrency { private set; get; } = int.MaxValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
@@ -156,13 +161,18 @@ namespace YooAsset
|
|||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
|
||||||
{
|
{
|
||||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
int convertValue = Convert.ToInt32(value);
|
||||||
|
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
@@ -210,8 +220,9 @@ namespace YooAsset
|
|||||||
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
||||||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||||
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||||
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY, FileVerifyMaxConcurrency);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, CopyLocalFileServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, CopyLocalFileServices);
|
||||||
@@ -335,6 +346,27 @@ namespace YooAsset
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否属于解压资源包文件
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool IsUnpackBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (Belong(bundle) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if UNITY_ANDROID || UNITY_OPENHARMONY
|
||||||
|
if (bundle.Encrypted)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultBuildinPackageRoot(string packageName)
|
protected string GetDefaultBuildinPackageRoot(string packageName)
|
||||||
{
|
{
|
||||||
@@ -370,27 +402,6 @@ namespace YooAsset
|
|||||||
return PathUtility.Combine(_packageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
return PathUtility.Combine(_packageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否属于解压资源包文件
|
|
||||||
/// </summary>
|
|
||||||
protected bool IsUnpackBundleFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
if (Belong(bundle) == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#if UNITY_ANDROID
|
|
||||||
if (bundle.Encrypted)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录文件信息
|
/// 记录文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,14 +8,18 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CopyBuildinManifest,
|
LoadBuildinPackageVersion,
|
||||||
|
CopyBuildinPackageHash,
|
||||||
|
CopyBuildinPackageManifest,
|
||||||
InitUnpackFileSystem,
|
InitUnpackFileSystem,
|
||||||
LoadCatalogFile,
|
LoadCatalogFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
private CopyBuildinPackageManifestOperation _copyBuildinPackageManifestOp;
|
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||||
|
private CopyBuildinFileOperation _copyBuildinHashFileOp;
|
||||||
|
private CopyBuildinFileOperation _copyBuildinManifestFileOp;
|
||||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
||||||
private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
|
private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
@@ -32,7 +36,7 @@ namespace YooAsset
|
|||||||
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
||||||
#else
|
#else
|
||||||
if (_fileSystem.CopyBuildinPackageManifest)
|
if (_fileSystem.CopyBuildinPackageManifest)
|
||||||
_steps = ESteps.CopyBuildinManifest;
|
_steps = ESteps.LoadBuildinPackageVersion;
|
||||||
else
|
else
|
||||||
_steps = ESteps.InitUnpackFileSystem;
|
_steps = ESteps.InitUnpackFileSystem;
|
||||||
#endif
|
#endif
|
||||||
@@ -42,20 +46,76 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.CopyBuildinManifest)
|
if (_steps == ESteps.LoadBuildinPackageVersion)
|
||||||
{
|
{
|
||||||
if (_copyBuildinPackageManifestOp == null)
|
if (_requestBuildinPackageVersionOp == null)
|
||||||
{
|
{
|
||||||
_copyBuildinPackageManifestOp = new CopyBuildinPackageManifestOperation(_fileSystem);
|
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||||
_copyBuildinPackageManifestOp.StartOperation();
|
_requestBuildinPackageVersionOp.StartOperation();
|
||||||
AddChildOperation(_copyBuildinPackageManifestOp);
|
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
_copyBuildinPackageManifestOp.UpdateOperation();
|
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||||
if (_copyBuildinPackageManifestOp.IsDone == false)
|
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_copyBuildinPackageManifestOp.Status == EOperationStatus.Succeed)
|
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CopyBuildinPackageHash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _requestBuildinPackageVersionOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyBuildinPackageHash)
|
||||||
|
{
|
||||||
|
if (_copyBuildinHashFileOp == null)
|
||||||
|
{
|
||||||
|
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||||
|
string destFilePath = GetCopyPackageHashDestPath(packageVersion);
|
||||||
|
string sourceFilePath = _fileSystem.GetBuildinPackageHashFilePath(packageVersion);
|
||||||
|
_copyBuildinHashFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||||
|
_copyBuildinHashFileOp.StartOperation();
|
||||||
|
AddChildOperation(_copyBuildinHashFileOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_copyBuildinHashFileOp.UpdateOperation();
|
||||||
|
if (_copyBuildinHashFileOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_copyBuildinHashFileOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CopyBuildinPackageManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _copyBuildinHashFileOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyBuildinPackageManifest)
|
||||||
|
{
|
||||||
|
if (_copyBuildinManifestFileOp == null)
|
||||||
|
{
|
||||||
|
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||||
|
string destFilePath = GetCopyPackageManifestDestPath(packageVersion);
|
||||||
|
string sourceFilePath = _fileSystem.GetBuildinPackageManifestFilePath(packageVersion);
|
||||||
|
_copyBuildinManifestFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||||
|
_copyBuildinManifestFileOp.StartOperation();
|
||||||
|
AddChildOperation(_copyBuildinManifestFileOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_copyBuildinManifestFileOp.UpdateOperation();
|
||||||
|
if (_copyBuildinManifestFileOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_copyBuildinManifestFileOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.InitUnpackFileSystem;
|
_steps = ESteps.InitUnpackFileSystem;
|
||||||
}
|
}
|
||||||
@@ -63,7 +123,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _copyBuildinPackageManifestOp.Error;
|
Error = _copyBuildinManifestFileOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +176,30 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
|
if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
var catalog = _loadBuildinCatalogFileOp.Catalog;
|
||||||
|
if (catalog == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Fatal error : catalog is null !";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalog.PackageName != _fileSystem.PackageName)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var wrapper in catalog.Wrappers)
|
||||||
|
{
|
||||||
|
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
||||||
|
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
@@ -127,5 +211,28 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetCopyManifestFileRoot()
|
||||||
|
{
|
||||||
|
string destRoot = _fileSystem.CopyBuildinPackageManifestDestRoot;
|
||||||
|
if (string.IsNullOrEmpty(destRoot))
|
||||||
|
{
|
||||||
|
string defaultCacheRoot = YooAssetSettingsData.GetYooDefaultCacheRoot();
|
||||||
|
destRoot = PathUtility.Combine(defaultCacheRoot, _fileSystem.PackageName, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||||
|
}
|
||||||
|
return destRoot;
|
||||||
|
}
|
||||||
|
private string GetCopyPackageHashDestPath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileRoot = GetCopyManifestFileRoot();
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(fileRoot, fileName);
|
||||||
|
}
|
||||||
|
private string GetCopyPackageManifestDestPath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileRoot = GetCopyManifestFileRoot();
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(fileRoot, fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class CopyBuildinFileOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CheckFileExist,
|
||||||
|
TryCopyFile,
|
||||||
|
UnpackFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private UnityWebFileRequestOperation _webFileRequestOp;
|
||||||
|
private readonly string _sourceFilePath;
|
||||||
|
private readonly string _destFilePath;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
public CopyBuildinFileOperation(string sourceFilePath, string destFilePath)
|
||||||
|
{
|
||||||
|
_sourceFilePath = sourceFilePath;
|
||||||
|
_destFilePath = destFilePath;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckFileExist;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckFileExist)
|
||||||
|
{
|
||||||
|
if (File.Exists(_destFilePath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.TryCopyFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.TryCopyFile)
|
||||||
|
{
|
||||||
|
if (File.Exists(_sourceFilePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var directory = Path.GetDirectoryName(_destFilePath);
|
||||||
|
if (Directory.Exists(directory) == false)
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
File.Copy(_sourceFilePath, _destFilePath, true);
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Failed copy buildin file : {ex.Message}");
|
||||||
|
_steps = ESteps.UnpackFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.UnpackFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UnpackFile)
|
||||||
|
{
|
||||||
|
if (_webFileRequestOp == null)
|
||||||
|
{
|
||||||
|
string url = DownloadSystemHelper.ConvertToWWWPath(_sourceFilePath);
|
||||||
|
_webFileRequestOp = new UnityWebFileRequestOperation(url, _destFilePath, 60);
|
||||||
|
_webFileRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webFileRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webFileRequestOp.UpdateOperation();
|
||||||
|
if (_webFileRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webFileRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webFileRequestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 40ef2e46f900131419e869398a8d3c9d
|
guid: bf44368bc5c2bf1479c36d82e931c295
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
internal class CopyBuildinPackageManifestOperation : AsyncOperationBase
|
|
||||||
{
|
|
||||||
private enum ESteps
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
RequestPackageVersion,
|
|
||||||
CheckHashFile,
|
|
||||||
UnpackHashFile,
|
|
||||||
CheckManifestFile,
|
|
||||||
UnpackManifestFile,
|
|
||||||
Done,
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
|
||||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
|
||||||
private UnityWebFileRequestOperation _hashWebFileRequestOp;
|
|
||||||
private UnityWebFileRequestOperation _manifestWebFileRequestOp;
|
|
||||||
private string _buildinPackageVersion;
|
|
||||||
private ESteps _steps = ESteps.None;
|
|
||||||
|
|
||||||
public CopyBuildinPackageManifestOperation(DefaultBuildinFileSystem fileSystem)
|
|
||||||
{
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
}
|
|
||||||
internal override void InternalStart()
|
|
||||||
{
|
|
||||||
_steps = ESteps.RequestPackageVersion;
|
|
||||||
}
|
|
||||||
internal override void InternalUpdate()
|
|
||||||
{
|
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_steps == ESteps.RequestPackageVersion)
|
|
||||||
{
|
|
||||||
if (_requestBuildinPackageVersionOp == null)
|
|
||||||
{
|
|
||||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
|
||||||
_requestBuildinPackageVersionOp.StartOperation();
|
|
||||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
|
||||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.CheckHashFile;
|
|
||||||
_buildinPackageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _requestBuildinPackageVersionOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.CheckHashFile)
|
|
||||||
{
|
|
||||||
string hashFilePath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
|
||||||
if (File.Exists(hashFilePath))
|
|
||||||
{
|
|
||||||
_steps = ESteps.CheckManifestFile;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_steps = ESteps.UnpackHashFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.UnpackHashFile)
|
|
||||||
{
|
|
||||||
if (_hashWebFileRequestOp == null)
|
|
||||||
{
|
|
||||||
string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion);
|
|
||||||
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
|
||||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
|
||||||
_hashWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
|
||||||
_hashWebFileRequestOp.StartOperation();
|
|
||||||
AddChildOperation(_hashWebFileRequestOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
_hashWebFileRequestOp.UpdateOperation();
|
|
||||||
if (_hashWebFileRequestOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_hashWebFileRequestOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.CheckManifestFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _hashWebFileRequestOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.CheckManifestFile)
|
|
||||||
{
|
|
||||||
string manifestFilePath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
|
||||||
if (File.Exists(manifestFilePath))
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_steps = ESteps.UnpackManifestFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.UnpackManifestFile)
|
|
||||||
{
|
|
||||||
if (_manifestWebFileRequestOp == null)
|
|
||||||
{
|
|
||||||
string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
|
|
||||||
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
|
||||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
|
||||||
_manifestWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
|
||||||
_manifestWebFileRequestOp.StartOperation();
|
|
||||||
AddChildOperation(_manifestWebFileRequestOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
_manifestWebFileRequestOp.UpdateOperation();
|
|
||||||
if (_manifestWebFileRequestOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_manifestWebFileRequestOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _manifestWebFileRequestOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetCopyManifestFileRoot()
|
|
||||||
{
|
|
||||||
string destRoot = _fileSystem.CopyBuildinPackageManifestDestRoot;
|
|
||||||
if (string.IsNullOrEmpty(destRoot))
|
|
||||||
{
|
|
||||||
string defaultCacheRoot = YooAssetSettingsData.GetYooDefaultCacheRoot();
|
|
||||||
destRoot = PathUtility.Combine(defaultCacheRoot, _fileSystem.PackageName, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
|
||||||
}
|
|
||||||
return destRoot;
|
|
||||||
}
|
|
||||||
private string GetCopyPackageHashDestPath(string packageVersion)
|
|
||||||
{
|
|
||||||
string fileRoot = GetCopyManifestFileRoot();
|
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, packageVersion);
|
|
||||||
return PathUtility.Combine(fileRoot, fileName);
|
|
||||||
}
|
|
||||||
private string GetCopyPackageManifestDestPath(string packageVersion)
|
|
||||||
{
|
|
||||||
string fileRoot = GetCopyManifestFileRoot();
|
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, packageVersion);
|
|
||||||
return PathUtility.Combine(fileRoot, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -7,29 +8,50 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
RequestData,
|
TryLoadFileData,
|
||||||
|
RequestFileData,
|
||||||
LoadCatalog,
|
LoadCatalog,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
|
private byte[] _fileData;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置资源目录
|
||||||
|
/// </summary>
|
||||||
|
public DefaultBuildinFileCatalog Catalog;
|
||||||
|
|
||||||
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestData;
|
_steps = ESteps.TryLoadFileData;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.RequestData)
|
if (_steps == ESteps.TryLoadFileData)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
_fileData = File.ReadAllBytes(filePath);
|
||||||
|
_steps = ESteps.LoadCatalog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestFileData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestFileData)
|
||||||
{
|
{
|
||||||
if (_webDataRequestOp == null)
|
if (_webDataRequestOp == null)
|
||||||
{
|
{
|
||||||
@@ -46,6 +68,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
_fileData = _webDataRequestOp.Result;
|
||||||
_steps = ESteps.LoadCatalog;
|
_steps = ESteps.LoadCatalog;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -60,22 +83,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var catalog = CatalogTools.DeserializeFromBinary(_webDataRequestOp.Result);
|
Catalog = CatalogTools.DeserializeFromBinary(_fileData);
|
||||||
if (catalog.PackageName != _fileSystem.PackageName)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var wrapper in catalog.Wrappers)
|
|
||||||
{
|
|
||||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
|
||||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class LoadBuildinPackageManifestOperation : AsyncOperationBase
|
internal class LoadBuildinPackageManifestOperation : AsyncOperationBase
|
||||||
@@ -6,6 +7,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
TryLoadFileData,
|
||||||
RequestFileData,
|
RequestFileData,
|
||||||
VerifyFileData,
|
VerifyFileData,
|
||||||
LoadManifest,
|
LoadManifest,
|
||||||
@@ -17,6 +19,7 @@ namespace YooAsset
|
|||||||
private readonly string _packageHash;
|
private readonly string _packageHash;
|
||||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
private DeserializeManifestOperation _deserializer;
|
private DeserializeManifestOperation _deserializer;
|
||||||
|
private byte[] _fileData;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,13 +36,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestFileData;
|
_steps = ESteps.TryLoadFileData;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.TryLoadFileData)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
_fileData = File.ReadAllBytes(filePath);
|
||||||
|
_steps = ESteps.VerifyFileData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestFileData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.RequestFileData)
|
if (_steps == ESteps.RequestFileData)
|
||||||
{
|
{
|
||||||
if (_webDataRequestOp == null)
|
if (_webDataRequestOp == null)
|
||||||
@@ -57,6 +74,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
_fileData = _webDataRequestOp.Result;
|
||||||
_steps = ESteps.VerifyFileData;
|
_steps = ESteps.VerifyFileData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -69,7 +87,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
@@ -85,7 +103,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_deserializer == null)
|
if (_deserializer == null)
|
||||||
{
|
{
|
||||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _webDataRequestOp.Result);
|
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _fileData);
|
||||||
_deserializer.StartOperation();
|
_deserializer.StartOperation();
|
||||||
AddChildOperation(_deserializer);
|
AddChildOperation(_deserializer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RequestBuildinPackageHashOperation : AsyncOperationBase
|
internal class RequestBuildinPackageHashOperation : AsyncOperationBase
|
||||||
@@ -6,7 +7,9 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
TryLoadPackageHash,
|
||||||
RequestPackageHash,
|
RequestPackageHash,
|
||||||
|
CheckResult,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,13 +31,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestPackageHash;
|
_steps = ESteps.TryLoadPackageHash;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.TryLoadPackageHash)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
PackageHash = File.ReadAllText(filePath);
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestPackageHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.RequestPackageHash)
|
if (_steps == ESteps.RequestPackageHash)
|
||||||
{
|
{
|
||||||
if (_webTextRequestOp == null)
|
if (_webTextRequestOp == null)
|
||||||
@@ -53,17 +70,7 @@ namespace YooAsset
|
|||||||
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
PackageHash = _webTextRequestOp.Result;
|
PackageHash = _webTextRequestOp.Result;
|
||||||
if (string.IsNullOrEmpty(PackageHash))
|
_steps = ESteps.CheckResult;
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Buildin package hash file content is empty !";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -72,6 +79,21 @@ namespace YooAsset
|
|||||||
Error = _webTextRequestOp.Error;
|
Error = _webTextRequestOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckResult)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(PackageHash))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Buildin package hash file content is empty !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RequestBuildinPackageVersionOperation : AsyncOperationBase
|
internal class RequestBuildinPackageVersionOperation : AsyncOperationBase
|
||||||
@@ -6,7 +7,9 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
TryLoadPackageVersion,
|
||||||
RequestPackageVersion,
|
RequestPackageVersion,
|
||||||
|
CheckResult,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,13 +29,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestPackageVersion;
|
_steps = ESteps.TryLoadPackageVersion;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.TryLoadPackageVersion)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
PackageVersion = File.ReadAllText(filePath);
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestPackageVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.RequestPackageVersion)
|
if (_steps == ESteps.RequestPackageVersion)
|
||||||
{
|
{
|
||||||
if (_webTextRequestOp == null)
|
if (_webTextRequestOp == null)
|
||||||
@@ -51,17 +68,7 @@ namespace YooAsset
|
|||||||
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
PackageVersion = _webTextRequestOp.Result;
|
PackageVersion = _webTextRequestOp.Result;
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
_steps = ESteps.CheckResult;
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Buildin package version file content is empty !";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -70,6 +77,21 @@ namespace YooAsset
|
|||||||
Error = _webTextRequestOp.Error;
|
Error = _webTextRequestOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckResult)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Buildin package version file content is empty !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,15 +60,20 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IRemoteServices RemoteServices { private set; get; }
|
public IRemoteServices RemoteServices { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:初始化的时候缓存文件校验级别
|
/// 自定义参数:初始化的时候缓存文件校验级别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:覆盖安装缓存清理模式
|
/// 自定义参数:初始化的时候缓存文件校验最大并发数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
public int FileVerifyMaxConcurrency { private set; get; } = int.MaxValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
@@ -215,13 +220,18 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
RemoteServices = (IRemoteServices)value;
|
RemoteServices = (IRemoteServices)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
|
||||||
{
|
{
|
||||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
int convertValue = Convert.ToInt32(value);
|
||||||
|
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
@@ -233,11 +243,13 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
|
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
|
||||||
{
|
{
|
||||||
DownloadMaxConcurrency = Convert.ToInt32(value);
|
int convertValue = Convert.ToInt32(value);
|
||||||
|
DownloadMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME)
|
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME)
|
||||||
{
|
{
|
||||||
DownloadMaxRequestPerFrame = Convert.ToInt32(value);
|
int convertValue = Convert.ToInt32(value);
|
||||||
|
DownloadMaxRequestPerFrame = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
|
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
|
||||||
{
|
{
|
||||||
@@ -493,22 +505,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
||||||
public void WriteBundleInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
public void WriteBundleInfoFile(string filePath, uint dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
_sharedBuffer.Clear();
|
_sharedBuffer.Clear();
|
||||||
_sharedBuffer.WriteUTF8(dataFileCRC);
|
_sharedBuffer.WriteUInt32(dataFileCRC);
|
||||||
_sharedBuffer.WriteInt64(dataFileSize);
|
_sharedBuffer.WriteInt64(dataFileSize);
|
||||||
_sharedBuffer.WriteToStream(fs);
|
_sharedBuffer.WriteToStream(fs);
|
||||||
fs.Flush();
|
fs.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void ReadBundleInfoFile(string filePath, out string dataFileCRC, out long dataFileSize)
|
public void ReadBundleInfoFile(string filePath, out uint dataFileCRC, out long dataFileSize)
|
||||||
{
|
{
|
||||||
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
||||||
BufferReader buffer = new BufferReader(binaryData);
|
BufferReader buffer = new BufferReader(binaryData);
|
||||||
dataFileCRC = buffer.ReadUTF8();
|
dataFileCRC = buffer.ReadUInt32();
|
||||||
dataFileSize = buffer.ReadInt64();
|
dataFileSize = buffer.ReadInt64();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public string InfoFilePath { private set; get; }
|
public string InfoFilePath { private set; get; }
|
||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string DataFileCRC { private set; get; }
|
public uint DataFileCRC { private set; get; }
|
||||||
public long DataFileSize { private set; get; }
|
public long DataFileSize { private set; get; }
|
||||||
|
|
||||||
public RecordFileElement(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
public RecordFileElement(string infoFilePath, string dataFilePath, uint dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
InfoFilePath = infoFilePath;
|
InfoFilePath = infoFilePath;
|
||||||
DataFilePath = dataFilePath;
|
DataFilePath = dataFilePath;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace YooAsset
|
|||||||
internal class TempFileElement
|
internal class TempFileElement
|
||||||
{
|
{
|
||||||
public string TempFilePath { private set; get; }
|
public string TempFilePath { private set; get; }
|
||||||
public string TempFileCRC { private set; get; }
|
public uint TempFileCRC { private set; get; }
|
||||||
public long TempFileSize { private set; get; }
|
public long TempFileSize { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public volatile int Result = 0;
|
public volatile int Result = 0;
|
||||||
|
|
||||||
public TempFileElement(string filePath, string fileCRC, long fileSize)
|
public TempFileElement(string filePath, uint fileCRC, long fileSize)
|
||||||
{
|
{
|
||||||
TempFilePath = filePath;
|
TempFilePath = filePath;
|
||||||
TempFileCRC = fileCRC;
|
TempFileCRC = fileCRC;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset
|
|||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string InfoFilePath { private set; get; }
|
public string InfoFilePath { private set; get; }
|
||||||
|
|
||||||
public string DataFileCRC;
|
public uint DataFileCRC;
|
||||||
public long DataFileSize;
|
public long DataFileSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -54,11 +54,13 @@ namespace YooAsset
|
|||||||
// 设置同时验证的最大数
|
// 设置同时验证的最大数
|
||||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
int threads = Math.Min(workerThreads, ioThreads);
|
||||||
|
_verifyMaxNum = Math.Min(threads, _fileSystem.FileVerifyMaxConcurrency);
|
||||||
_verifyTotalCount = fileCount;
|
_verifyTotalCount = fileCount;
|
||||||
if (_verifyMaxNum < 1)
|
if (_verifyMaxNum < 1)
|
||||||
_verifyMaxNum = 1;
|
_verifyMaxNum = 1;
|
||||||
|
|
||||||
|
YooLogger.Log($"Verify max concurrency : {_verifyMaxNum}");
|
||||||
_verifyingList = new List<VerifyFileElement>(_verifyMaxNum);
|
_verifyingList = new List<VerifyFileElement>(_verifyMaxNum);
|
||||||
_steps = ESteps.UpdateVerify;
|
_steps = ESteps.UpdateVerify;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace YooAsset
|
|||||||
public class FileSystemParametersDefine
|
public class FileSystemParametersDefine
|
||||||
{
|
{
|
||||||
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||||
|
public const string FILE_VERIFY_MAX_CONCURRENCY = "FILE_VERIFY_MAX_CONCURRENCY";
|
||||||
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
||||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验
|
/// 文件校验
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EFileVerifyResult FileVerify(string filePath, long fileSize, string fileCRC, EFileVerifyLevel verifyLevel)
|
public static EFileVerifyResult FileVerify(string filePath, long fileSize, uint fileCRC, EFileVerifyLevel verifyLevel)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
|||||||
// 再验证文件CRC
|
// 再验证文件CRC
|
||||||
if (verifyLevel == EFileVerifyLevel.High)
|
if (verifyLevel == EFileVerifyLevel.High)
|
||||||
{
|
{
|
||||||
string crc = HashUtility.FileCRC32(filePath);
|
uint crc = HashUtility.FileCRC32Value(filePath);
|
||||||
if (crc == fileCRC)
|
if (crc == fileCRC)
|
||||||
return EFileVerifyResult.Succeed;
|
return EFileVerifyResult.Succeed;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace YooAsset
|
|||||||
|
|
||||||
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(1000);
|
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(1000);
|
||||||
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(1000);
|
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(1000);
|
||||||
|
private static Action<string, AsyncOperationBase> _startCallback = null;
|
||||||
|
private static Action<string, AsyncOperationBase> _finishCallback = null;
|
||||||
|
|
||||||
// 计时器相关
|
// 计时器相关
|
||||||
private static Stopwatch _watch;
|
private static Stopwatch _watch;
|
||||||
@@ -33,6 +36,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
// NOTE : 单次调用开销约1微秒
|
||||||
return _watch.ElapsedMilliseconds - _frameTime >= MaxTimeSlice;
|
return _watch.ElapsedMilliseconds - _frameTime >= MaxTimeSlice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +61,12 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
var operation = _operations[i];
|
var operation = _operations[i];
|
||||||
if (operation.IsFinish)
|
if (operation.IsFinish)
|
||||||
|
{
|
||||||
_operations.RemoveAt(i);
|
_operations.RemoveAt(i);
|
||||||
|
|
||||||
|
if (_finishCallback != null)
|
||||||
|
_finishCallback.Invoke(operation.PackageName, operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加新增的异步操作
|
// 添加新增的异步操作
|
||||||
@@ -82,10 +91,11 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新进行中的异步操作
|
// 更新进行中的异步操作
|
||||||
|
bool checkBusy = MaxTimeSlice < long.MaxValue;
|
||||||
_frameTime = _watch.ElapsedMilliseconds;
|
_frameTime = _watch.ElapsedMilliseconds;
|
||||||
for (int i = 0; i < _operations.Count; i++)
|
for (int i = 0; i < _operations.Count; i++)
|
||||||
{
|
{
|
||||||
if (IsBusy)
|
if (checkBusy && IsBusy)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var operation = _operations[i];
|
var operation = _operations[i];
|
||||||
@@ -103,6 +113,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_operations.Clear();
|
_operations.Clear();
|
||||||
_newList.Clear();
|
_newList.Clear();
|
||||||
|
_startCallback = null;
|
||||||
|
_finishCallback = null;
|
||||||
_watch = null;
|
_watch = null;
|
||||||
_frameTime = 0;
|
_frameTime = 0;
|
||||||
MaxTimeSlice = long.MaxValue;
|
MaxTimeSlice = long.MaxValue;
|
||||||
@@ -140,6 +152,25 @@ namespace YooAsset
|
|||||||
_newList.Add(operation);
|
_newList.Add(operation);
|
||||||
operation.SetPackageName(packageName);
|
operation.SetPackageName(packageName);
|
||||||
operation.StartOperation();
|
operation.StartOperation();
|
||||||
|
|
||||||
|
if (_startCallback != null)
|
||||||
|
_startCallback.Invoke(packageName, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 监听任务开始
|
||||||
|
/// </summary>
|
||||||
|
public static void RegisterStartCallback(Action<string, AsyncOperationBase> callback)
|
||||||
|
{
|
||||||
|
_startCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 监听任务结束
|
||||||
|
/// </summary>
|
||||||
|
public static void RegisterFinishCallback(Action<string, AsyncOperationBase> callback)
|
||||||
|
{
|
||||||
|
_finishCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件格式版本
|
/// 文件格式版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string FileVersion = "2.3.1";
|
public const string FileVersion = "2025.8.28";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,6 +59,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 写入文件头信息
|
// 写入文件头信息
|
||||||
buffer.WriteBool(manifest.EnableAddressable);
|
buffer.WriteBool(manifest.EnableAddressable);
|
||||||
|
buffer.WriteBool(manifest.SupportExtensionless);
|
||||||
buffer.WriteBool(manifest.LocationToLower);
|
buffer.WriteBool(manifest.LocationToLower);
|
||||||
buffer.WriteBool(manifest.IncludeAssetGUID);
|
buffer.WriteBool(manifest.IncludeAssetGUID);
|
||||||
buffer.WriteInt32(manifest.OutputNameStyle);
|
buffer.WriteInt32(manifest.OutputNameStyle);
|
||||||
@@ -89,7 +90,7 @@ namespace YooAsset
|
|||||||
buffer.WriteUTF8(packageBundle.BundleName);
|
buffer.WriteUTF8(packageBundle.BundleName);
|
||||||
buffer.WriteUInt32(packageBundle.UnityCRC);
|
buffer.WriteUInt32(packageBundle.UnityCRC);
|
||||||
buffer.WriteUTF8(packageBundle.FileHash);
|
buffer.WriteUTF8(packageBundle.FileHash);
|
||||||
buffer.WriteUTF8(packageBundle.FileCRC);
|
buffer.WriteUInt32(packageBundle.FileCRC);
|
||||||
buffer.WriteInt64(packageBundle.FileSize);
|
buffer.WriteInt64(packageBundle.FileSize);
|
||||||
buffer.WriteBool(packageBundle.Encrypted);
|
buffer.WriteBool(packageBundle.Encrypted);
|
||||||
buffer.WriteUTF8Array(packageBundle.Tags);
|
buffer.WriteUTF8Array(packageBundle.Tags);
|
||||||
@@ -153,6 +154,7 @@ namespace YooAsset
|
|||||||
// 读取文件头信息
|
// 读取文件头信息
|
||||||
manifest.FileVersion = fileVersion;
|
manifest.FileVersion = fileVersion;
|
||||||
manifest.EnableAddressable = buffer.ReadBool();
|
manifest.EnableAddressable = buffer.ReadBool();
|
||||||
|
manifest.SupportExtensionless = buffer.ReadBool();
|
||||||
manifest.LocationToLower = buffer.ReadBool();
|
manifest.LocationToLower = buffer.ReadBool();
|
||||||
manifest.IncludeAssetGUID = buffer.ReadBool();
|
manifest.IncludeAssetGUID = buffer.ReadBool();
|
||||||
manifest.OutputNameStyle = buffer.ReadInt32();
|
manifest.OutputNameStyle = buffer.ReadInt32();
|
||||||
@@ -190,7 +192,7 @@ namespace YooAsset
|
|||||||
packageBundle.BundleName = buffer.ReadUTF8();
|
packageBundle.BundleName = buffer.ReadUTF8();
|
||||||
packageBundle.UnityCRC = buffer.ReadUInt32();
|
packageBundle.UnityCRC = buffer.ReadUInt32();
|
||||||
packageBundle.FileHash = buffer.ReadUTF8();
|
packageBundle.FileHash = buffer.ReadUTF8();
|
||||||
packageBundle.FileCRC = buffer.ReadUTF8();
|
packageBundle.FileCRC = buffer.ReadUInt32();
|
||||||
packageBundle.FileSize = buffer.ReadInt64();
|
packageBundle.FileSize = buffer.ReadInt64();
|
||||||
packageBundle.Encrypted = buffer.ReadBool();
|
packageBundle.Encrypted = buffer.ReadBool();
|
||||||
packageBundle.Tags = buffer.ReadUTF8Array();
|
packageBundle.Tags = buffer.ReadUTF8Array();
|
||||||
@@ -280,13 +282,16 @@ namespace YooAsset
|
|||||||
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
|
|
||||||
// 添加无后缀名路径的映射
|
// 添加无后缀名路径的映射
|
||||||
string locationWithoutExtension = Path.ChangeExtension(location, null);
|
if (manifest.SupportExtensionless)
|
||||||
if (ReferenceEquals(location, locationWithoutExtension) == false)
|
|
||||||
{
|
{
|
||||||
if (manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
|
string locationWithoutExtension = Path.ChangeExtension(location, null);
|
||||||
YooLogger.Warning($"Location have existed : {locationWithoutExtension}");
|
if (ReferenceEquals(location, locationWithoutExtension) == false)
|
||||||
else
|
{
|
||||||
manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
|
if (manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
|
||||||
|
YooLogger.Warning($"Location have existed : {locationWithoutExtension}");
|
||||||
|
else
|
||||||
|
manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ namespace YooAsset
|
|||||||
Manifest = new PackageManifest();
|
Manifest = new PackageManifest();
|
||||||
Manifest.FileVersion = fileVersion;
|
Manifest.FileVersion = fileVersion;
|
||||||
Manifest.EnableAddressable = _buffer.ReadBool();
|
Manifest.EnableAddressable = _buffer.ReadBool();
|
||||||
|
Manifest.SupportExtensionless = _buffer.ReadBool();
|
||||||
Manifest.LocationToLower = _buffer.ReadBool();
|
Manifest.LocationToLower = _buffer.ReadBool();
|
||||||
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
||||||
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
||||||
@@ -159,7 +160,7 @@ namespace YooAsset
|
|||||||
packageBundle.BundleName = _buffer.ReadUTF8();
|
packageBundle.BundleName = _buffer.ReadUTF8();
|
||||||
packageBundle.UnityCRC = _buffer.ReadUInt32();
|
packageBundle.UnityCRC = _buffer.ReadUInt32();
|
||||||
packageBundle.FileHash = _buffer.ReadUTF8();
|
packageBundle.FileHash = _buffer.ReadUTF8();
|
||||||
packageBundle.FileCRC = _buffer.ReadUTF8();
|
packageBundle.FileCRC = _buffer.ReadUInt32();
|
||||||
packageBundle.FileSize = _buffer.ReadInt64();
|
packageBundle.FileSize = _buffer.ReadInt64();
|
||||||
packageBundle.Encrypted = _buffer.ReadBool();
|
packageBundle.Encrypted = _buffer.ReadBool();
|
||||||
packageBundle.Tags = _buffer.ReadUTF8Array();
|
packageBundle.Tags = _buffer.ReadUTF8Array();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileCRC;
|
public uint FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持无后缀名的资源定位地址
|
||||||
|
/// </summary>
|
||||||
|
public bool SupportExtensionless;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持无后缀名的资源定位地址
|
||||||
|
/// </summary>
|
||||||
|
public bool SupportExtensionless;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -116,6 +121,7 @@ namespace YooAsset
|
|||||||
PackageDetails details = new PackageDetails();
|
PackageDetails details = new PackageDetails();
|
||||||
details.FileVersion = FileVersion;
|
details.FileVersion = FileVersion;
|
||||||
details.EnableAddressable = EnableAddressable;
|
details.EnableAddressable = EnableAddressable;
|
||||||
|
details.SupportExtensionless = SupportExtensionless;
|
||||||
details.LocationToLower = LocationToLower;
|
details.LocationToLower = LocationToLower;
|
||||||
details.IncludeAssetGUID = IncludeAssetGUID;
|
details.IncludeAssetGUID = IncludeAssetGUID;
|
||||||
details.OutputNameStyle = OutputNameStyle;
|
details.OutputNameStyle = OutputNameStyle;
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace YooAsset
|
|||||||
/// 预下载指定版本的包裹资源
|
/// 预下载指定版本的包裹资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">包裹版本</param>
|
/// <param name="packageVersion">包裹版本</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">资源清单下载的超时时间(默认值:60秒)</param>
|
||||||
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
|
|||||||
@@ -73,6 +73,17 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private uint _currentCrc;
|
private uint _currentCrc;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the computed hash value.
|
||||||
|
/// </summary>
|
||||||
|
public uint CRCValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _currentCrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="CRC32Algorithm"/> class.
|
/// Initializes a new instance of the <see cref="CRC32Algorithm"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -339,6 +339,11 @@ namespace YooAsset
|
|||||||
byte[] buffer = Encoding.UTF8.GetBytes(str);
|
byte[] buffer = Encoding.UTF8.GetBytes(str);
|
||||||
return BytesCRC32(buffer);
|
return BytesCRC32(buffer);
|
||||||
}
|
}
|
||||||
|
public static uint StringCRC32Value(string str)
|
||||||
|
{
|
||||||
|
byte[] buffer = Encoding.UTF8.GetBytes(str);
|
||||||
|
return BytesCRC32Value(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取文件的CRC32
|
/// 获取文件的CRC32
|
||||||
@@ -350,6 +355,13 @@ namespace YooAsset
|
|||||||
return StreamCRC32(fs);
|
return StreamCRC32(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static uint FileCRC32Value(string filePath)
|
||||||
|
{
|
||||||
|
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
|
{
|
||||||
|
return StreamCRC32Value(fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取文件的CRC32
|
/// 获取文件的CRC32
|
||||||
@@ -366,6 +378,18 @@ namespace YooAsset
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static uint FileCRC32ValueSafely(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return FileCRC32Value(filePath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Exception(e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取数据流的CRC32
|
/// 获取数据流的CRC32
|
||||||
@@ -376,6 +400,12 @@ namespace YooAsset
|
|||||||
byte[] hashBytes = hash.ComputeHash(stream);
|
byte[] hashBytes = hash.ComputeHash(stream);
|
||||||
return ToString(hashBytes);
|
return ToString(hashBytes);
|
||||||
}
|
}
|
||||||
|
public static uint StreamCRC32Value(Stream stream)
|
||||||
|
{
|
||||||
|
CRC32Algorithm hash = new CRC32Algorithm();
|
||||||
|
hash.ComputeHash(stream);
|
||||||
|
return hash.CRCValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取字节数组的CRC32
|
/// 获取字节数组的CRC32
|
||||||
@@ -386,6 +416,12 @@ namespace YooAsset
|
|||||||
byte[] hashBytes = hash.ComputeHash(buffer);
|
byte[] hashBytes = hash.ComputeHash(buffer);
|
||||||
return ToString(hashBytes);
|
return ToString(hashBytes);
|
||||||
}
|
}
|
||||||
|
public static uint BytesCRC32Value(byte[] buffer)
|
||||||
|
{
|
||||||
|
CRC32Algorithm hash = new CRC32Algorithm();
|
||||||
|
hash.ComputeHash(buffer);
|
||||||
|
return hash.CRCValue;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 64b064347ca7a404494a996b072e2e29
|
guid: f450f29c62aedae4390edc923f71811d
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class CreateBuildinCatalogWindow : EditorWindow
|
||||||
|
{
|
||||||
|
static CreateBuildinCatalogWindow _thisInstance;
|
||||||
|
|
||||||
|
[MenuItem("Tools/内置清单生成工具(Catalog)", false, 101)]
|
||||||
|
static void ShowWindow()
|
||||||
|
{
|
||||||
|
if (_thisInstance == null)
|
||||||
|
{
|
||||||
|
_thisInstance = EditorWindow.GetWindow(typeof(CreateBuildinCatalogWindow), false, "内置清单生成工具", true) as CreateBuildinCatalogWindow;
|
||||||
|
_thisInstance.minSize = new Vector2(800, 600);
|
||||||
|
}
|
||||||
|
_thisInstance.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _directoryRoot = string.Empty;
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Space(10);
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
if (GUILayout.Button("选择内置资源目录", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
string resultPath = EditorUtility.OpenFolderPanel("Find", "Assets/", "StreamingAssets");
|
||||||
|
if (!string.IsNullOrEmpty(resultPath))
|
||||||
|
_directoryRoot = resultPath;
|
||||||
|
}
|
||||||
|
EditorGUILayout.LabelField(_directoryRoot);
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_directoryRoot) == false)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("生成Catalog文件", GUILayout.MaxWidth(150)))
|
||||||
|
{
|
||||||
|
CreateCatalogFile(_directoryRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateCatalogFile(string directoryRoot)
|
||||||
|
{
|
||||||
|
// 搜索所有Package目录
|
||||||
|
List<string> packageRoots = GetPackageRoots(directoryRoot);
|
||||||
|
foreach (var packageRoot in packageRoots)
|
||||||
|
{
|
||||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(packageRoot);
|
||||||
|
string packageName = directoryInfo.Name;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool result = CatalogTools.CreateCatalogFile(null, packageName, packageRoot); //TODO 自行处理解密
|
||||||
|
if (result == false)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Create package {packageName} catalog file failed ! See the detail error in console !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Create package {packageName} catalog file failed ! {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<string> GetPackageRoots(string rootPath)
|
||||||
|
{
|
||||||
|
// 检查目录是否存在
|
||||||
|
if (Directory.Exists(rootPath) == false)
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException($"目录不存在: {rootPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索所有 .version 文件(包含子目录)
|
||||||
|
string[] versionFiles = Directory.GetFiles(
|
||||||
|
rootPath,
|
||||||
|
"*.version",
|
||||||
|
SearchOption.AllDirectories
|
||||||
|
);
|
||||||
|
|
||||||
|
// 提取文件所在目录路径并去重
|
||||||
|
return versionFiles
|
||||||
|
.Select(file => Path.GetDirectoryName(file))
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 69f62f6b4185d06498f96aa272e9b926
|
guid: 16ab831593388974fa7e8f8c7e8199a8
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a5b9231662e24c942b544bd85d4b39cb
|
guid: e8f5ca9e913008d4988fe0f4a2f4a443
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using YooAsset.Editor;
|
||||||
|
|
||||||
|
[BuildPipelineAttribute("CustomBuildPipeline")]
|
||||||
|
internal class CustomBuildPipelineViewer : BuiltinBuildPipelineViewer
|
||||||
|
{
|
||||||
|
protected override string GetDefaultPackageVersion()
|
||||||
|
{
|
||||||
|
return "v1.0.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 52e2d973a2156674e8c1c9433ed031f7
|
guid: e721201eb2cad4e4ca207b9c99208055
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 275b87293edc6634f9d72387851dbbdf
|
guid: c0c72b92f8bf3db4b9920e968e43b2df
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
public static class OperationMonitor
|
||||||
|
{
|
||||||
|
public static void RegisterOperationCallback()
|
||||||
|
{
|
||||||
|
OperationSystem.RegisterStartCallback(OperationStartCallback);
|
||||||
|
OperationSystem.RegisterFinishCallback(OperationFinishCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OperationStartCallback(string packageName, AsyncOperationBase operation)
|
||||||
|
{
|
||||||
|
Debug.Log($"Operation start : {operation.GetType().Name}");
|
||||||
|
}
|
||||||
|
private static void OperationFinishCallback(string packageName, AsyncOperationBase operation)
|
||||||
|
{
|
||||||
|
Debug.Log($"Operation finish : {operation.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5bee3e3860e37484aa3b861bf76d129f
|
guid: fecc774089972ae4eaecb16bdaf9d319
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 25cb2f742bfeb1d48a4e65d3140b955d
|
guid: 7d2280a83472bd14bb033f506647284d
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using YooAsset;
|
||||||
|
using AlipaySdk;
|
||||||
|
|
||||||
|
public static class AlipayFileSystemCreater
|
||||||
|
{
|
||||||
|
public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteServices remoteServices)
|
||||||
|
{
|
||||||
|
string fileSystemClass = $"{nameof(AlipayFileSystem)},YooAsset.MiniGame";
|
||||||
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
|
return fileSystemParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteServices remoteServices, IWebDecryptionServices decryptionServices)
|
||||||
|
{
|
||||||
|
string fileSystemClass = $"{nameof(AlipayFileSystem)},YooAsset.MiniGame";
|
||||||
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
|
return fileSystemParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付宝小游戏文件系统
|
||||||
|
/// 参考:https://opendocs.alipay.com/mini-game/0ftleg
|
||||||
|
/// </summary>
|
||||||
|
internal class AlipayFileSystem : IFileSystem
|
||||||
|
{
|
||||||
|
private class WebRemoteServices : IRemoteServices
|
||||||
|
{
|
||||||
|
private readonly string _webPackageRoot;
|
||||||
|
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
|
||||||
|
|
||||||
|
public WebRemoteServices(string buildinPackRoot)
|
||||||
|
{
|
||||||
|
_webPackageRoot = buildinPackRoot;
|
||||||
|
}
|
||||||
|
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||||
|
{
|
||||||
|
return GetFileLoadURL(fileName);
|
||||||
|
}
|
||||||
|
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
||||||
|
{
|
||||||
|
return GetFileLoadURL(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetFileLoadURL(string fileName)
|
||||||
|
{
|
||||||
|
if (_mapping.TryGetValue(fileName, out string url) == false)
|
||||||
|
{
|
||||||
|
string filePath = PathUtility.Combine(_webPackageRoot, fileName);
|
||||||
|
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||||
|
_mapping.Add(fileName, url);
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Dictionary<string, string> _cacheFilePathMapping = new Dictionary<string, string>(10000);
|
||||||
|
private AlipayFSManager _fileSystemMgr;
|
||||||
|
private string _aliCacheRoot = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件根目录
|
||||||
|
/// </summary>
|
||||||
|
public string FileRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _aliCacheRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件数量
|
||||||
|
/// </summary>
|
||||||
|
public int FileCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 自定义参数
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:远程服务接口
|
||||||
|
/// </summary>
|
||||||
|
public IRemoteServices RemoteServices { private set; get; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:解密方法类
|
||||||
|
/// </summary>
|
||||||
|
public IWebDecryptionServices DecryptionServices { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:资源清单服务类
|
||||||
|
/// </summary>
|
||||||
|
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public AlipayFileSystem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||||
|
{
|
||||||
|
var operation = new APFSInitializeOperation(this);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new APFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new APFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
|
{
|
||||||
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
|
{
|
||||||
|
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||||
|
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||||
|
options.SetURL(mainURL, fallbackURL);
|
||||||
|
var operation = new APFSDownloadFileOperation(this, bundle, options);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||||
|
{
|
||||||
|
var operation = new APFSLoadBundleOperation(this, bundle);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string error = $"{nameof(AlipayFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||||
|
var operation = new FSLoadBundleCompleteOperation(error);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetParameter(string name, object value)
|
||||||
|
{
|
||||||
|
if (name == FileSystemParametersDefine.REMOTE_SERVICES)
|
||||||
|
{
|
||||||
|
RemoteServices = (IRemoteServices)value;
|
||||||
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||||
|
{
|
||||||
|
DecryptionServices = (IWebDecryptionServices)value;
|
||||||
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||||
|
{
|
||||||
|
ManifestServices = (IManifestRestoreServices)value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual void OnCreate(string packageName, string rootDirectory)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
_aliCacheRoot = rootDirectory;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_aliCacheRoot))
|
||||||
|
{
|
||||||
|
throw new System.Exception("请配置支付宝小游戏的缓存根目录!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:CDN服务未启用的情况下,使用支付宝WEB服务器
|
||||||
|
if (RemoteServices == null)
|
||||||
|
{
|
||||||
|
string webRoot = PathUtility.Combine(Application.streamingAssetsPath, YooAssetSettingsData.Setting.DefaultYooFolderName, packageName);
|
||||||
|
RemoteServices = new WebRemoteServices(webRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
_fileSystemMgr = AlipaySDK.API.GetFileSystemManager();
|
||||||
|
}
|
||||||
|
public virtual void OnDestroy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Belong(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return CheckCacheFileExist(bundle);
|
||||||
|
}
|
||||||
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (Belong(bundle) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Exists(bundle) == false;
|
||||||
|
}
|
||||||
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string GetBundleFilePath(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
return GetCacheFileLoadPath(bundle);
|
||||||
|
}
|
||||||
|
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (CheckCacheFileExist(bundle))
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
return _fileSystemMgr.ReadFileSync(filePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Array.Empty<byte>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual string ReadBundleFileText(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (CheckCacheFileExist(bundle))
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
return _fileSystemMgr.ReadFileSync(filePath, "utf8");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 内部方法
|
||||||
|
public AlipayFSManager GetFileSystemMgr()
|
||||||
|
{
|
||||||
|
return _fileSystemMgr;
|
||||||
|
}
|
||||||
|
public bool CheckCacheFileExist(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
//TODO : 效率极低
|
||||||
|
/*
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
string result = _fileSystemMgr.AccessSync(filePath);
|
||||||
|
return result.Equals("access:ok", StringComparison.Ordinal);
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private string GetCacheFileLoadPath(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (_cacheFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||||
|
{
|
||||||
|
filePath = PathUtility.Combine(_aliCacheRoot, bundle.FileName);
|
||||||
|
_cacheFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||||
|
}
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 61be9965c7f7aae468a34b3ed38116b5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 44b9746ed3270394eb54d85b27a2ef04
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using AlipaySdk;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class APAssetBundleResult : BundleResult
|
||||||
|
{
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly PackageBundle _packageBundle;
|
||||||
|
private readonly AssetBundle _assetBundle;
|
||||||
|
|
||||||
|
public APAssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageBundle = packageBundle;
|
||||||
|
_assetBundle = assetBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UnloadBundleFile()
|
||||||
|
{
|
||||||
|
if (_assetBundle != null)
|
||||||
|
{
|
||||||
|
if (_packageBundle.Encrypted)
|
||||||
|
_assetBundle.Unload(true);
|
||||||
|
else
|
||||||
|
_assetBundle.APUnload(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override string GetBundleFilePath()
|
||||||
|
{
|
||||||
|
return _fileSystem.GetBundleFilePath(_packageBundle);
|
||||||
|
}
|
||||||
|
public override byte[] ReadBundleFileData()
|
||||||
|
{
|
||||||
|
return _fileSystem.ReadBundleFileData(_packageBundle);
|
||||||
|
}
|
||||||
|
public override string ReadBundleFileText()
|
||||||
|
{
|
||||||
|
return _fileSystem.ReadBundleFileText(_packageBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
var operation = new AssetBundleLoadAssetOperation(_packageBundle, _assetBundle, assetInfo);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
var operation = new AssetBundleLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
var operation = new AssetBundleLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
|
||||||
|
{
|
||||||
|
var operation = new AssetBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1de437726bd89584da56aaddfdb1a07c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 18ae5147de9585045ab40941d945696b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using UnityEngine;
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class APFSDownloadFileOperation : FSDownloadFileOperation
|
||||||
|
{
|
||||||
|
protected enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CreateRequest,
|
||||||
|
CheckRequest,
|
||||||
|
TryAgain,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
private readonly DownloadFileOptions _options;
|
||||||
|
private UnityWebCacheRequestOperation _webCacheRequestOp;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private float _tryAgainTimer;
|
||||||
|
private int _failedTryAgain;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
internal APFSDownloadFileOperation(AlipayFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CreateRequest;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
// 创建下载器
|
||||||
|
if (_steps == ESteps.CreateRequest)
|
||||||
|
{
|
||||||
|
string url = GetRequestURL();
|
||||||
|
_webCacheRequestOp = new UnityWebCacheRequestOperation(url);
|
||||||
|
_webCacheRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webCacheRequestOp);
|
||||||
|
_steps = ESteps.CheckRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测下载结果
|
||||||
|
if (_steps == ESteps.CheckRequest)
|
||||||
|
{
|
||||||
|
_webCacheRequestOp.UpdateOperation();
|
||||||
|
Progress = _webCacheRequestOp.Progress;
|
||||||
|
DownloadProgress = _webCacheRequestOp.DownloadProgress;
|
||||||
|
DownloadedBytes = _webCacheRequestOp.DownloadedBytes;
|
||||||
|
if (_webCacheRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webCacheRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
|
||||||
|
//TODO 需要验证插件请求器的下载进度
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = Bundle.FileSize;
|
||||||
|
Progress = 1f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_failedTryAgain > 0)
|
||||||
|
{
|
||||||
|
_steps = ESteps.TryAgain;
|
||||||
|
YooLogger.Warning($"Failed download : {_webCacheRequestOp.URL} Try again !");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webCacheRequestOp.Error;
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新尝试下载
|
||||||
|
if (_steps == ESteps.TryAgain)
|
||||||
|
{
|
||||||
|
_tryAgainTimer += Time.unscaledDeltaTime;
|
||||||
|
if (_tryAgainTimer > 1f)
|
||||||
|
{
|
||||||
|
_tryAgainTimer = 0f;
|
||||||
|
_failedTryAgain--;
|
||||||
|
Progress = 0f;
|
||||||
|
DownloadProgress = 0f;
|
||||||
|
DownloadedBytes = 0;
|
||||||
|
_steps = ESteps.CreateRequest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取网络请求地址
|
||||||
|
/// </summary>
|
||||||
|
private string GetRequestURL()
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
_requestCount++;
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _options.FallbackURL;
|
||||||
|
else
|
||||||
|
return _options.MainURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bc47317a416e9f542b7ec6b77485a8b7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal partial class APFSInitializeOperation : FSInitializeFileSystemOperation
|
||||||
|
{
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
|
||||||
|
public APFSInitializeOperation(AlipayFileSystem fileSystem)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 71a99a94d7563fe4a9d56ea0e15aa8d1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class APFSLoadBundleOperation : FSLoadBundleOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadAssetBundle,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
private readonly PackageBundle _bundle;
|
||||||
|
private LoadWebAssetBundleOperation _loadWebAssetBundleOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
internal APFSLoadBundleOperation(AlipayFileSystem fileSystem, PackageBundle bundle)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_bundle = bundle;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadAssetBundle;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadAssetBundle)
|
||||||
|
{
|
||||||
|
if (_loadWebAssetBundleOp == null)
|
||||||
|
{
|
||||||
|
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||||
|
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||||
|
options.SetURL(mainURL, fallbackURL);
|
||||||
|
|
||||||
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices);
|
||||||
|
_loadWebAssetBundleOp.StartOperation();
|
||||||
|
AddChildOperation(_loadWebAssetBundleOp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_loadWebAssetBundleOp = new LoadAlipayAssetBundleOperation(_bundle, options);
|
||||||
|
_loadWebAssetBundleOp.StartOperation();
|
||||||
|
AddChildOperation(_loadWebAssetBundleOp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_loadWebAssetBundleOp.UpdateOperation();
|
||||||
|
Progress = _loadWebAssetBundleOp.Progress;
|
||||||
|
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
||||||
|
DownloadedBytes = _loadWebAssetBundleOp.DownloadedBytes;
|
||||||
|
if (_loadWebAssetBundleOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_loadWebAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
var assetBundle = _loadWebAssetBundleOp.Result;
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Result = new APAssetBundleResult(_fileSystem, _bundle, assetBundle);
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _loadWebAssetBundleOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
{
|
||||||
|
if (_steps != ESteps.Done)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "WebGL platform not support sync load method !";
|
||||||
|
UnityEngine.Debug.LogError(Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f71fc4fc468d41441b00be64938b2fe9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class APFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageHash,
|
||||||
|
LoadPackageManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private RequestAlipayPackageHashOperation _requestPackageHashOp;
|
||||||
|
private LoadAlipayPackageManifestOperation _loadPackageManifestOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
public APFSLoadPackageManifestOperation(AlipayFileSystem 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 (_requestPackageHashOp == null)
|
||||||
|
{
|
||||||
|
_requestPackageHashOp = new RequestAlipayPackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||||
|
_requestPackageHashOp.StartOperation();
|
||||||
|
AddChildOperation(_requestPackageHashOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_requestPackageHashOp.UpdateOperation();
|
||||||
|
if (_requestPackageHashOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_requestPackageHashOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadPackageManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _requestPackageHashOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadPackageManifest)
|
||||||
|
{
|
||||||
|
if (_loadPackageManifestOp == null)
|
||||||
|
{
|
||||||
|
string packageHash = _requestPackageHashOp.PackageHash;
|
||||||
|
_loadPackageManifestOp = new LoadAlipayPackageManifestOperation(_fileSystem, _packageVersion, packageHash, _timeout);
|
||||||
|
_loadPackageManifestOp.StartOperation();
|
||||||
|
AddChildOperation(_loadPackageManifestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_loadPackageManifestOp.UpdateOperation();
|
||||||
|
Progress = _loadPackageManifestOp.Progress;
|
||||||
|
if (_loadPackageManifestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Manifest = _loadPackageManifestOp.Manifest;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _loadPackageManifestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 335885fb4e1977a4ca5c26263eda03d7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class APFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
private readonly bool _appendTimeTicks;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private RequestAlipayPackageVersionOperation _requestWebPackageVersionOp;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
internal APFSRequestPackageVersionOperation(AlipayFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_appendTimeTicks = appendTimeTicks;
|
||||||
|
_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 RequestAlipayPackageVersionOperation(_fileSystem, _appendTimeTicks, _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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a879fd6a506b37345b4b9ea6c5de20bc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b94d7bcfa19151046a1f0ed8e089a474
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using UnityEngine;
|
||||||
|
using AlipaySdk;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class LoadAlipayAssetBundleOperation : LoadWebAssetBundleOperation
|
||||||
|
{
|
||||||
|
protected enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CreateRequest,
|
||||||
|
CheckRequest,
|
||||||
|
TryAgain,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly PackageBundle _bundle;
|
||||||
|
private readonly DownloadFileOptions _options;
|
||||||
|
private UnityAlipayAssetBundleRequestOperation _unityAssetBundleRequestOp;
|
||||||
|
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private float _tryAgainTimer;
|
||||||
|
private int _failedTryAgain;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
internal LoadAlipayAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options)
|
||||||
|
{
|
||||||
|
_bundle = bundle;
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CreateRequest;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 创建下载器
|
||||||
|
if (_steps == ESteps.CreateRequest)
|
||||||
|
{
|
||||||
|
string url = GetRequestURL();
|
||||||
|
_unityAssetBundleRequestOp = new UnityAlipayAssetBundleRequestOperation(_bundle, url);
|
||||||
|
_unityAssetBundleRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_unityAssetBundleRequestOp);
|
||||||
|
_steps = ESteps.CheckRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测下载结果
|
||||||
|
if (_steps == ESteps.CheckRequest)
|
||||||
|
{
|
||||||
|
_unityAssetBundleRequestOp.UpdateOperation();
|
||||||
|
Progress = _unityAssetBundleRequestOp.Progress;
|
||||||
|
DownloadProgress = _unityAssetBundleRequestOp.DownloadProgress;
|
||||||
|
DownloadedBytes = _unityAssetBundleRequestOp.DownloadedBytes;
|
||||||
|
if (_unityAssetBundleRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_unityAssetBundleRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
Result = _unityAssetBundleRequestOp.Result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_failedTryAgain > 0)
|
||||||
|
{
|
||||||
|
_steps = ESteps.TryAgain;
|
||||||
|
YooLogger.Warning($"Failed download : {_unityAssetBundleRequestOp.URL} Try again !");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _unityAssetBundleRequestOp.Error;
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新尝试下载
|
||||||
|
if (_steps == ESteps.TryAgain)
|
||||||
|
{
|
||||||
|
_tryAgainTimer += Time.unscaledDeltaTime;
|
||||||
|
if (_tryAgainTimer > 1f)
|
||||||
|
{
|
||||||
|
_tryAgainTimer = 0f;
|
||||||
|
_failedTryAgain--;
|
||||||
|
Progress = 0f;
|
||||||
|
DownloadProgress = 0f;
|
||||||
|
DownloadedBytes = 0;
|
||||||
|
_steps = ESteps.CreateRequest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取网络请求地址
|
||||||
|
/// </summary>
|
||||||
|
private string GetRequestURL()
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
_requestCount++;
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _options.FallbackURL;
|
||||||
|
else
|
||||||
|
return _options.MainURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62249d32580e2ef48a33afb58515312a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class LoadAlipayPackageManifestOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestFileData,
|
||||||
|
VerifyFileData,
|
||||||
|
LoadManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly string _packageHash;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
|
private DeserializeManifestOperation _deserializer;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹清单
|
||||||
|
/// </summary>
|
||||||
|
public PackageManifest Manifest { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
internal LoadAlipayPackageManifestOperation(AlipayFileSystem fileSystem, string packageVersion, string packageHash, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_packageHash = packageHash;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(LoadAlipayPackageManifestOperation));
|
||||||
|
_steps = ESteps.RequestFileData;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestFileData)
|
||||||
|
{
|
||||||
|
if (_webDataRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
|
||||||
|
string url = GetRequestURL(fileName);
|
||||||
|
_webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
|
||||||
|
_webDataRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webDataRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webDataRequestOp.UpdateOperation();
|
||||||
|
Progress = _webDataRequestOp.Progress;
|
||||||
|
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(LoadAlipayPackageManifestOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 package manifest file!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadManifest)
|
||||||
|
{
|
||||||
|
if (_deserializer == null)
|
||||||
|
{
|
||||||
|
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c802e6ad51754e144bb4e08942da9592
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class RequestAlipayPackageHashOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageHash,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _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 RequestAlipayPackageHashOperation(AlipayFileSystem fileSystem, string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestAlipayPackageHashOperation));
|
||||||
|
_steps = ESteps.RequestPackageHash;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageHash)
|
||||||
|
{
|
||||||
|
if (_webTextRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, _packageVersion);
|
||||||
|
string url = GetRequestURL(fileName);
|
||||||
|
_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 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(RequestAlipayPackageHashOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (_requestCount % 2 == 0)
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b4f8cf6fe34a7e419f8e3a0063f591b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
internal class RequestAlipayPackageVersionOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly AlipayFileSystem _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; }
|
||||||
|
|
||||||
|
|
||||||
|
public RequestAlipayPackageVersionOperation(AlipayFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_appendTimeTicks = appendTimeTicks;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestAlipayPackageVersionOperation));
|
||||||
|
_steps = ESteps.RequestPackageVersion;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageVersion)
|
||||||
|
{
|
||||||
|
if (_webTextRequestOp == null)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_fileSystem.PackageName);
|
||||||
|
string url = GetRequestURL(fileName);
|
||||||
|
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||||
|
_webTextRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webTextRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webTextRequestOp.UpdateOperation();
|
||||||
|
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 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(RequestAlipayPackageVersionOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRequestURL(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ef3d88ce51a6fa47be1b157316a740c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
#if UNITY_WEBGL && UNITY_ALIMINIGAME
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine;
|
||||||
|
using AlipaySdk;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class UnityAlipayAssetBundleRequestOperation : UnityWebRequestOperation
|
||||||
|
{
|
||||||
|
protected enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CreateRequest,
|
||||||
|
Download,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly PackageBundle _packageBundle;
|
||||||
|
private UnityWebRequestAsyncOperation _requestOperation;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求结果
|
||||||
|
/// </summary>
|
||||||
|
public AssetBundle Result { private set; get; }
|
||||||
|
|
||||||
|
internal UnityAlipayAssetBundleRequestOperation(PackageBundle bundle, string url) : base(url)
|
||||||
|
{
|
||||||
|
_packageBundle = bundle;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CreateRequest;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CreateRequest)
|
||||||
|
{
|
||||||
|
CreateWebRequest();
|
||||||
|
_steps = ESteps.Download;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.Download)
|
||||||
|
{
|
||||||
|
DownloadProgress = _webRequest.downloadProgress;
|
||||||
|
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||||
|
Progress = _requestOperation.progress;
|
||||||
|
if (_requestOperation.isDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CheckRequestResult())
|
||||||
|
{
|
||||||
|
var downloadHanlder = (DownloadHandlerAPAssetBundle)_webRequest.downloadHandler;
|
||||||
|
AssetBundle assetBundle = downloadHanlder.assetBundle;
|
||||||
|
if (assetBundle == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"URL : {_requestURL} Download handler asset bundle object is null !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Result = assetBundle;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
|
||||||
|
//TODO 需要验证插件请求器的下载进度
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = _packageBundle.FileSize;
|
||||||
|
Progress = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:最终释放请求器
|
||||||
|
DisposeRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateWebRequest()
|
||||||
|
{
|
||||||
|
_webRequest = APAssetBundle.GetAssetBundle(_requestURL);
|
||||||
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
|
_requestOperation = _webRequest.SendWebRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2e7a4e37ac067f4ba0a43ebea0aa3f6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -48,7 +48,7 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
|
|||||||
_webCacheRequestOp.UpdateOperation();
|
_webCacheRequestOp.UpdateOperation();
|
||||||
Progress = _webCacheRequestOp.Progress;
|
Progress = _webCacheRequestOp.Progress;
|
||||||
DownloadProgress = _webCacheRequestOp.DownloadProgress;
|
DownloadProgress = _webCacheRequestOp.DownloadProgress;
|
||||||
DownloadedBytes = (long)_webCacheRequestOp.DownloadedBytes;
|
DownloadedBytes = _webCacheRequestOp.DownloadedBytes;
|
||||||
if (_webCacheRequestOp.IsDone == false)
|
if (_webCacheRequestOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
|
||||||
//TODO 需要验证抖音插件请求器的下载进度
|
//TODO 需要验证插件请求器的下载进度
|
||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = Bundle.FileSize;
|
DownloadedBytes = Bundle.FileSize;
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#if UNITY_WEBGL && DOUYINMINIGAME
|
#if UNITY_WEBGL && DOUYINMINIGAME
|
||||||
using UnityEngine;
|
|
||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
||||||
@@ -7,7 +6,7 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
DownloadAssetBundle,
|
LoadAssetBundle,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,14 +22,14 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadAssetBundle;
|
_steps = ESteps.LoadAssetBundle;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.DownloadAssetBundle)
|
if (_steps == ESteps.LoadAssetBundle)
|
||||||
{
|
{
|
||||||
if (_loadWebAssetBundleOp == null)
|
if (_loadWebAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
@@ -56,7 +55,7 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
|||||||
_loadWebAssetBundleOp.UpdateOperation();
|
_loadWebAssetBundleOp.UpdateOperation();
|
||||||
Progress = _loadWebAssetBundleOp.Progress;
|
Progress = _loadWebAssetBundleOp.Progress;
|
||||||
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
||||||
DownloadedBytes = (long)_loadWebAssetBundleOp.DownloadedBytes;
|
DownloadedBytes = _loadWebAssetBundleOp.DownloadedBytes;
|
||||||
if (_loadWebAssetBundleOp.IsDone == false)
|
if (_loadWebAssetBundleOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
private readonly PackageBundle _bundle;
|
private readonly PackageBundle _bundle;
|
||||||
private readonly DownloadFileOptions _options;
|
private readonly DownloadFileOptions _options;
|
||||||
private UnityTiktokAssetBundleRequestOperation _unityTiktokAssetBundleRequestOp;
|
private UnityTiktokAssetBundleRequestOperation _unityAssetBundleRequestOp;
|
||||||
|
|
||||||
private int _requestCount = 0;
|
private int _requestCount = 0;
|
||||||
private float _tryAgainTimer;
|
private float _tryAgainTimer;
|
||||||
@@ -42,40 +42,40 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.CreateRequest)
|
if (_steps == ESteps.CreateRequest)
|
||||||
{
|
{
|
||||||
string url = GetRequestURL();
|
string url = GetRequestURL();
|
||||||
_unityTiktokAssetBundleRequestOp = new UnityTiktokAssetBundleRequestOperation(_bundle, url);
|
_unityAssetBundleRequestOp = new UnityTiktokAssetBundleRequestOperation(_bundle, url);
|
||||||
_unityTiktokAssetBundleRequestOp.StartOperation();
|
_unityAssetBundleRequestOp.StartOperation();
|
||||||
AddChildOperation(_unityTiktokAssetBundleRequestOp);
|
AddChildOperation(_unityAssetBundleRequestOp);
|
||||||
_steps = ESteps.CheckRequest;
|
_steps = ESteps.CheckRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测下载结果
|
// 检测下载结果
|
||||||
if (_steps == ESteps.CheckRequest)
|
if (_steps == ESteps.CheckRequest)
|
||||||
{
|
{
|
||||||
_unityTiktokAssetBundleRequestOp.UpdateOperation();
|
_unityAssetBundleRequestOp.UpdateOperation();
|
||||||
Progress = _unityTiktokAssetBundleRequestOp.Progress;
|
Progress = _unityAssetBundleRequestOp.Progress;
|
||||||
DownloadProgress = _unityTiktokAssetBundleRequestOp.DownloadProgress;
|
DownloadProgress = _unityAssetBundleRequestOp.DownloadProgress;
|
||||||
DownloadedBytes = (long)_unityTiktokAssetBundleRequestOp.DownloadedBytes;
|
DownloadedBytes = _unityAssetBundleRequestOp.DownloadedBytes;
|
||||||
if (_unityTiktokAssetBundleRequestOp.IsDone == false)
|
if (_unityAssetBundleRequestOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_unityTiktokAssetBundleRequestOp.Status == EOperationStatus.Succeed)
|
if (_unityAssetBundleRequestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
Result = _unityTiktokAssetBundleRequestOp.Result;
|
Result = _unityAssetBundleRequestOp.Result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_failedTryAgain > 0)
|
if (_failedTryAgain > 0)
|
||||||
{
|
{
|
||||||
_steps = ESteps.TryAgain;
|
_steps = ESteps.TryAgain;
|
||||||
YooLogger.Warning($"Failed download : {_unityTiktokAssetBundleRequestOp.URL} Try again !");
|
YooLogger.Warning($"Failed download : {_unityAssetBundleRequestOp.URL} Try again !");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _unityTiktokAssetBundleRequestOp.Error;
|
Error = _unityAssetBundleRequestOp.Error;
|
||||||
YooLogger.Error(Error);
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ internal class RequestTiktokPackageHashOperation : AsyncOperationBase
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Wechat package hash file content is empty !";
|
Error = $"Web package hash file content is empty !";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ internal class RequestTiktokPackageVersionOperation : AsyncOperationBase
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Wechat package version file content is empty !";
|
Error = $"Web package version file content is empty !";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace YooAsset
|
|||||||
Result = assetBundle;
|
Result = assetBundle;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
|
||||||
//TODO 需要验证抖音插件请求器的下载进度
|
//TODO 需要验证插件请求器的下载进度
|
||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = _packageBundle.FileSize;
|
DownloadedBytes = _packageBundle.FileSize;
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#if UNITY_WEBGL && DOUYINMINIGAME
|
#if UNITY_WEBGL && DOUYINMINIGAME
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using YooAsset;
|
using YooAsset;
|
||||||
using TTSDK;
|
using TTSDK;
|
||||||
using System.Linq;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public static class TiktokFileSystemCreater
|
public static class TiktokFileSystemCreater
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user