mirror of https://github.com/tuyoogame/YooAsset
Compare commits
8 Commits
4599ff098c
...
4e9c1955eb
Author | SHA1 | Date |
---|---|---|
|
4e9c1955eb | |
|
b6c68a533e | |
|
38aa1c3509 | |
|
eb2f783417 | |
|
8556e071fa | |
|
6155256fb6 | |
|
0d4f2bc893 | |
|
600e928ab4 |
|
@ -2,6 +2,15 @@
|
||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [2.3.5-preview] - 2025-03-14
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#502) 修复了原生缓存文件由于文件格式变动导致的加载本地缓存文件失败的问题。
|
||||||
|
- (#504) 修复了MacOS平台Offline Play Mode模式请求本地资源清单失败的问题。
|
||||||
|
- (#506) 修复了v2.3x版本LoadAllAssets方法计算依赖Bundle不完整的问题。
|
||||||
|
- (#506) 修复了微信小游戏文件系统,在启用加密算法后卸载bundle报错的问题。
|
||||||
|
|
||||||
## [2.3.4-preview] - 2025-03-08
|
## [2.3.4-preview] - 2025-03-08
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生成内置资源记录文件
|
||||||
|
/// </summary>
|
||||||
|
internal void CreateCatalogFile(BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||||
|
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||||
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(buildPackageName, buildinRootDirectory);
|
||||||
|
|
||||||
|
// 刷新目录
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d2c835e5e40ca34d93480587c8125df
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -30,7 +30,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_BBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fe3d00b03dc9c64a96b7acfdf99b54c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
||||||
new TaskCreateReport_BBP(),
|
new TaskCreateReport_BBP(),
|
||||||
new TaskCreatePackage_BBP(),
|
new TaskCreatePackage_BBP(),
|
||||||
new TaskCopyBuildinFiles_BBP(),
|
new TaskCopyBuildinFiles_BBP(),
|
||||||
|
new TaskCreateCatalog_BBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_RFBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 563771ecaff17ee498b5fda7c1132e62
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
||||||
new TaskCreateReport_RFBP(),
|
new TaskCreateReport_RFBP(),
|
||||||
new TaskCreatePackage_RFBP(),
|
new TaskCreatePackage_RFBP(),
|
||||||
new TaskCopyBuildinFiles_RFBP(),
|
new TaskCopyBuildinFiles_RFBP(),
|
||||||
|
new TaskCreateCatalog_RFBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_SBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d8241b1eb8e22874b84d279dae9bbd1b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
||||||
new TaskCreateReport_SBP(),
|
new TaskCreateReport_SBP(),
|
||||||
new TaskCreatePackage_SBP(),
|
new TaskCreatePackage_SBP(),
|
||||||
new TaskCopyBuildinFiles_SBP(),
|
new TaskCopyBuildinFiles_SBP(),
|
||||||
|
new TaskCreateCatalog_SBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class CatalogDefine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件极限大小(100MB)
|
||||||
|
/// </summary>
|
||||||
|
public const int FileMaxSize = 104857600;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件头标记
|
||||||
|
/// </summary>
|
||||||
|
public const uint FileSign = 0x133C5EE;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件格式版本
|
||||||
|
/// </summary>
|
||||||
|
public const string FileVersion = "1.0.0";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c6be7b8be0b51784997c959b370193e9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,102 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal static class CatalogTools
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 序列化(JSON文件)
|
||||||
|
/// </summary>
|
||||||
|
public static void SerializeToJson(string savePath, DefaultBuildinFileCatalog catalog)
|
||||||
|
{
|
||||||
|
string json = JsonUtility.ToJson(catalog, true);
|
||||||
|
FileUtility.WriteAllText(savePath, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化(JSON文件)
|
||||||
|
/// </summary>
|
||||||
|
public static DefaultBuildinFileCatalog DeserializeFromJson(string jsonContent)
|
||||||
|
{
|
||||||
|
return JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列化(二进制文件)
|
||||||
|
/// </summary>
|
||||||
|
public static void SerializeToBinary(string savePath, DefaultBuildinFileCatalog catalog)
|
||||||
|
{
|
||||||
|
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||||
|
{
|
||||||
|
// 创建缓存器
|
||||||
|
BufferWriter buffer = new BufferWriter(CatalogDefine.FileMaxSize);
|
||||||
|
|
||||||
|
// 写入文件标记
|
||||||
|
buffer.WriteUInt32(CatalogDefine.FileSign);
|
||||||
|
|
||||||
|
// 写入文件版本
|
||||||
|
buffer.WriteUTF8(CatalogDefine.FileVersion);
|
||||||
|
|
||||||
|
// 写入文件头信息
|
||||||
|
buffer.WriteUTF8(catalog.PackageName);
|
||||||
|
buffer.WriteUTF8(catalog.PackageVersion);
|
||||||
|
|
||||||
|
// 写入资源包列表
|
||||||
|
buffer.WriteInt32(catalog.Wrappers.Count);
|
||||||
|
for (int i = 0; i < catalog.Wrappers.Count; i++)
|
||||||
|
{
|
||||||
|
var fileWrapper = catalog.Wrappers[i];
|
||||||
|
buffer.WriteUTF8(fileWrapper.BundleGUID);
|
||||||
|
buffer.WriteUTF8(fileWrapper.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写入文件流
|
||||||
|
buffer.WriteToStream(fs);
|
||||||
|
fs.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化(二进制文件)
|
||||||
|
/// </summary>
|
||||||
|
public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData)
|
||||||
|
{
|
||||||
|
// 创建缓存器
|
||||||
|
BufferReader buffer = new BufferReader(binaryData);
|
||||||
|
|
||||||
|
// 读取文件标记
|
||||||
|
uint fileSign = buffer.ReadUInt32();
|
||||||
|
if (fileSign != CatalogDefine.FileSign)
|
||||||
|
throw new Exception("Invalid catalog file !");
|
||||||
|
|
||||||
|
// 读取文件版本
|
||||||
|
string fileVersion = buffer.ReadUTF8();
|
||||||
|
if (fileVersion != CatalogDefine.FileVersion)
|
||||||
|
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogDefine.FileVersion}");
|
||||||
|
|
||||||
|
DefaultBuildinFileCatalog catalog = new DefaultBuildinFileCatalog();
|
||||||
|
{
|
||||||
|
// 读取文件头信息
|
||||||
|
catalog.FileVersion = fileVersion;
|
||||||
|
catalog.PackageName = buffer.ReadUTF8();
|
||||||
|
catalog.PackageVersion = buffer.ReadUTF8();
|
||||||
|
|
||||||
|
// 读取资源包列表
|
||||||
|
int fileCount = buffer.ReadInt32();
|
||||||
|
catalog.Wrappers = new List<DefaultBuildinFileCatalog.FileWrapper>(fileCount);
|
||||||
|
for (int i = 0; i < fileCount; i++)
|
||||||
|
{
|
||||||
|
var fileWrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||||
|
fileWrapper.BundleGUID = buffer.ReadUTF8();
|
||||||
|
fileWrapper.FileName = buffer.ReadUTF8();
|
||||||
|
catalog.Wrappers.Add(fileWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cf87ffe3b3de69942ac16640a330dd37
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,27 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置资源清单目录
|
/// 内置资源清单目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class DefaultBuildinFileCatalog : ScriptableObject
|
[Serializable]
|
||||||
|
internal class DefaultBuildinFileCatalog
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class FileWrapper
|
public class FileWrapper
|
||||||
{
|
{
|
||||||
public string BundleGUID;
|
public string BundleGUID;
|
||||||
public string FileName;
|
public string FileName;
|
||||||
|
|
||||||
public FileWrapper(string bundleGUID, string fileName)
|
|
||||||
{
|
|
||||||
BundleGUID = bundleGUID;
|
|
||||||
FileName = fileName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件版本
|
||||||
|
/// </summary>
|
||||||
|
public string FileVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -336,10 +336,9 @@ namespace YooAsset
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||||
return PathUtility.Combine(_packageRoot, fileName);
|
return PathUtility.Combine(_packageRoot, fileName);
|
||||||
}
|
}
|
||||||
public string GetCatalogFileLoadPath()
|
public string GetCatalogBinaryFileLoadPath()
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(DefaultBuildinFileSystemDefine.BuildinCatalogFileName);
|
return PathUtility.Combine(_packageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||||
return YooAssetSettingsData.GetYooResourcesLoadPath(PackageName, fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -17,10 +17,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
YooLogger.Log("Begin to create catalog file !");
|
YooLogger.Log("Begin to create catalog file !");
|
||||||
|
|
||||||
string savePath = YooAssetSettingsData.GetYooResourcesFullPath();
|
|
||||||
if (UnityEditor.AssetDatabase.DeleteAsset(savePath))
|
|
||||||
UnityEditor.AssetDatabase.Refresh();
|
|
||||||
|
|
||||||
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists == false)
|
if (rootDirectory.Exists == false)
|
||||||
|
@ -87,10 +83,25 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建内置清单实例
|
// 创建内置清单实例
|
||||||
var buildinFileCatalog = ScriptableObject.CreateInstance<DefaultBuildinFileCatalog>();
|
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
||||||
|
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||||
buildinFileCatalog.PackageName = packageName;
|
buildinFileCatalog.PackageName = packageName;
|
||||||
buildinFileCatalog.PackageVersion = packageVersion;
|
buildinFileCatalog.PackageVersion = packageVersion;
|
||||||
|
|
||||||
|
// 创建白名单查询集合
|
||||||
|
HashSet<string> whiteFileList = new HashSet<string>
|
||||||
|
{
|
||||||
|
"link.xml",
|
||||||
|
"buildlogtep.json",
|
||||||
|
$"{packageName}.version",
|
||||||
|
$"{packageName}_{packageVersion}.bytes",
|
||||||
|
$"{packageName}_{packageVersion}.hash",
|
||||||
|
$"{packageName}_{packageVersion}.json",
|
||||||
|
$"{packageName}_{packageVersion}.report",
|
||||||
|
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
|
||||||
|
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
|
||||||
|
};
|
||||||
|
|
||||||
// 记录所有内置资源文件
|
// 记录所有内置资源文件
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(pacakgeDirectory);
|
DirectoryInfo rootDirectory = new DirectoryInfo(pacakgeDirectory);
|
||||||
FileInfo[] fileInfos = rootDirectory.GetFiles();
|
FileInfo[] fileInfos = rootDirectory.GetFiles();
|
||||||
|
@ -99,23 +110,15 @@ namespace YooAsset
|
||||||
if (fileInfo.Extension == ".meta")
|
if (fileInfo.Extension == ".meta")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fileInfo.Name == "link.xml" || fileInfo.Name == "buildlogtep.json")
|
if (whiteFileList.Contains(fileInfo.Name))
|
||||||
continue;
|
|
||||||
if (fileInfo.Name == $"{packageName}.version")
|
|
||||||
continue;
|
|
||||||
if (fileInfo.Name == $"{packageName}_{packageVersion}.bytes")
|
|
||||||
continue;
|
|
||||||
if (fileInfo.Name == $"{packageName}_{packageVersion}.hash")
|
|
||||||
continue;
|
|
||||||
if (fileInfo.Name == $"{packageName}_{packageVersion}.json")
|
|
||||||
continue;
|
|
||||||
if (fileInfo.Name == $"{packageName}_{packageVersion}.report")
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string fileName = fileInfo.Name;
|
string fileName = fileInfo.Name;
|
||||||
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
||||||
{
|
{
|
||||||
var wrapper = new DefaultBuildinFileCatalog.FileWrapper(bundleGUID, fileName);
|
var wrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||||
|
wrapper.BundleGUID = bundleGUID;
|
||||||
|
wrapper.FileName = fileName;
|
||||||
buildinFileCatalog.Wrappers.Add(wrapper);
|
buildinFileCatalog.Wrappers.Add(wrapper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -124,21 +127,20 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建输出目录
|
// 创建输出文件
|
||||||
string fullPath = YooAssetSettingsData.GetYooResourcesFullPath();
|
string jsonFilePath = $"{pacakgeDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
|
||||||
string saveFilePath = $"{fullPath}/{packageName}/{DefaultBuildinFileSystemDefine.BuildinCatalogFileName}";
|
if (File.Exists(jsonFilePath))
|
||||||
FileUtility.CreateFileDirectory(saveFilePath);
|
File.Delete(jsonFilePath);
|
||||||
|
CatalogTools.SerializeToJson(jsonFilePath, buildinFileCatalog);
|
||||||
|
|
||||||
// 创建输出文件
|
// 创建输出文件
|
||||||
UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath);
|
string binaryFilePath = $"{pacakgeDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
|
||||||
UnityEditor.EditorUtility.SetDirty(buildinFileCatalog);
|
if (File.Exists(binaryFilePath))
|
||||||
#if UNITY_2019
|
File.Delete(binaryFilePath);
|
||||||
UnityEditor.AssetDatabase.SaveAssets();
|
CatalogTools.SerializeToBinary(binaryFilePath, buildinFileCatalog);
|
||||||
#else
|
|
||||||
UnityEditor.AssetDatabase.SaveAssetIfDirty(buildinFileCatalog);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
|
UnityEditor.AssetDatabase.Refresh();
|
||||||
|
Debug.Log($"Succeed to save buildin file catalog : {binaryFilePath}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,13 @@ namespace YooAsset
|
||||||
internal class DefaultBuildinFileSystemDefine
|
internal class DefaultBuildinFileSystemDefine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置清单文件名称
|
/// 内置清单JSON文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string BuildinCatalogFileName = "BuildinCatalog.asset";
|
public const string BuildinCatalogJsonFileName = "BuildinCatalog.json";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置清单二进制文件名称
|
||||||
|
/// </summary>
|
||||||
|
public const string BuildinCatalogBinaryFileName = "BuildinCatalog.bytes";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
using UnityEngine;
|
using System;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -7,56 +7,84 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
RequestData,
|
||||||
LoadCatalog,
|
LoadCatalog,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadCatalog;
|
_steps = ESteps.RequestData;
|
||||||
}
|
}
|
||||||
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 (_webDataRequestOp == null)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
|
||||||
|
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||||
|
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||||
|
_webDataRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webDataRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webDataRequestOp.UpdateOperation();
|
||||||
|
if (_webDataRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadCatalog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webDataRequestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCatalog)
|
if (_steps == ESteps.LoadCatalog)
|
||||||
{
|
{
|
||||||
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
try
|
||||||
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
{
|
||||||
if (catalog == null)
|
var catalog = CatalogTools.DeserializeFromBinary(_webDataRequestOp.Result);
|
||||||
|
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;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load catalog file : {catalogFilePath}";
|
Error = $"Failed to load catalog file : {e.Message}";
|
||||||
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;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,6 +333,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
return _records.Keys.ToList();
|
return _records.Keys.ToList();
|
||||||
}
|
}
|
||||||
|
public RecordFileElement GetRecordFileElement(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element))
|
||||||
|
return element;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public string GetTempFilePath(PackageBundle bundle)
|
public string GetTempFilePath(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
|
@ -384,10 +391,10 @@ namespace YooAsset
|
||||||
|
|
||||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element) == false)
|
||||||
return EFileVerifyResult.CacheNotFound;
|
return EFileVerifyResult.CacheNotFound;
|
||||||
|
|
||||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, EFileVerifyLevel.High);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
||||||
|
@ -427,10 +434,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
if (_records.TryGetValue(bundleGUID, out RecordFileElement element))
|
||||||
{
|
{
|
||||||
_records.Remove(bundleGUID);
|
_records.Remove(bundleGUID);
|
||||||
return wrapper.DeleteFolder();
|
return element.DeleteFolder();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
|
@ -260,9 +261,30 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_fileSystem.Exists(_bundle))
|
if (_fileSystem.Exists(_bundle))
|
||||||
{
|
{
|
||||||
DownloadProgress = 1f;
|
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
|
||||||
DownloadedBytes = _bundle.FileSize;
|
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
|
||||||
_steps = ESteps.LoadCacheRawBundle;
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var recordFileElement = _fileSystem.GetRecordFileElement(_bundle);
|
||||||
|
File.Move(recordFileElement.DataFilePath, filePath);
|
||||||
|
_steps = ESteps.LoadCacheRawBundle;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Faild rename raw data file : {e.Message}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = _bundle.FileSize;
|
||||||
|
_steps = ESteps.LoadCacheRawBundle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,12 +92,7 @@ namespace YooAsset
|
||||||
if (_fileSystem.AppendFileExtension)
|
if (_fileSystem.AppendFileExtension)
|
||||||
{
|
{
|
||||||
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||||
if (string.IsNullOrEmpty(dataFileExtension))
|
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||||
{
|
|
||||||
//注意:覆盖安装的情况下,缓存文件可能会没有后缀格式,需要删除重新下载!
|
|
||||||
dataFilePath = string.Empty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
dataFilePath += dataFileExtension;
|
dataFilePath += dataFileExtension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,10 +198,9 @@ namespace YooAsset
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||||
return PathUtility.Combine(FileRoot, fileName);
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
}
|
}
|
||||||
public string GetCatalogFileLoadPath()
|
public string GetCatalogBinaryFileLoadPath()
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(DefaultBuildinFileSystemDefine.BuildinCatalogFileName);
|
return PathUtility.Combine(_webPackageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||||
return YooAssetSettingsData.GetYooResourcesLoadPath(PackageName, fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -11,61 +10,84 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
RequestData,
|
||||||
LoadCatalog,
|
LoadCatalog,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
|
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置清单版本
|
|
||||||
/// </summary>
|
|
||||||
public string PackageVersion { private set; get; }
|
|
||||||
|
|
||||||
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
|
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadCatalog;
|
_steps = ESteps.RequestData;
|
||||||
}
|
}
|
||||||
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 (_webDataRequestOp == null)
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
|
||||||
|
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||||
|
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||||
|
_webDataRequestOp.StartOperation();
|
||||||
|
AddChildOperation(_webDataRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webDataRequestOp.UpdateOperation();
|
||||||
|
if (_webDataRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadCatalog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _webDataRequestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCatalog)
|
if (_steps == ESteps.LoadCatalog)
|
||||||
{
|
{
|
||||||
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
try
|
||||||
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
{
|
||||||
if (catalog == null)
|
var catalog = CatalogTools.DeserializeFromBinary(_webDataRequestOp.Result);
|
||||||
|
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 DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
||||||
|
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
Error = $"Failed to load catalog file : {e.Message}";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (catalog.PackageName != _fileSystem.PackageName)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PackageVersion = catalog.PackageVersion;
|
|
||||||
foreach (var wrapper in catalog.Wrappers)
|
|
||||||
{
|
|
||||||
var fileWrapper = new DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
|
||||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public class ManifestDefine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件极限大小(100MB)
|
||||||
|
/// </summary>
|
||||||
|
public const int FileMaxSize = 104857600;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件头标记
|
||||||
|
/// </summary>
|
||||||
|
public const uint FileSign = 0x594F4F;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件格式版本
|
||||||
|
/// </summary>
|
||||||
|
public const string FileVersion = "2.3.1";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3282b72521a19144292a482e50ba0429
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,7 +8,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
internal static class ManifestTools
|
internal static class ManifestTools
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化(JSON文件)
|
/// 序列化(JSON文件)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -26,10 +25,10 @@ namespace YooAsset
|
||||||
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||||
{
|
{
|
||||||
// 创建缓存器
|
// 创建缓存器
|
||||||
BufferWriter buffer = new BufferWriter(YooAssetSettings.ManifestFileMaxSize);
|
BufferWriter buffer = new BufferWriter(ManifestDefine.FileMaxSize);
|
||||||
|
|
||||||
// 写入文件标记
|
// 写入文件标记
|
||||||
buffer.WriteUInt32(YooAssetSettings.ManifestFileSign);
|
buffer.WriteUInt32(ManifestDefine.FileSign);
|
||||||
|
|
||||||
// 写入文件版本
|
// 写入文件版本
|
||||||
buffer.WriteUTF8(manifest.FileVersion);
|
buffer.WriteUTF8(manifest.FileVersion);
|
||||||
|
@ -97,13 +96,13 @@ namespace YooAsset
|
||||||
|
|
||||||
// 读取文件标记
|
// 读取文件标记
|
||||||
uint fileSign = buffer.ReadUInt32();
|
uint fileSign = buffer.ReadUInt32();
|
||||||
if (fileSign != YooAssetSettings.ManifestFileSign)
|
if (fileSign != ManifestDefine.FileSign)
|
||||||
throw new Exception("Invalid manifest file !");
|
throw new Exception("Invalid manifest file !");
|
||||||
|
|
||||||
// 读取文件版本
|
// 读取文件版本
|
||||||
string fileVersion = buffer.ReadUTF8();
|
string fileVersion = buffer.ReadUTF8();
|
||||||
if (fileVersion != YooAssetSettings.ManifestFileVersion)
|
if (fileVersion != ManifestDefine.FileVersion)
|
||||||
throw new Exception($"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.ManifestFileVersion}");
|
throw new Exception($"The manifest file version are not compatible : {fileVersion} != {ManifestDefine.FileVersion}");
|
||||||
|
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
{
|
{
|
||||||
|
@ -160,7 +159,7 @@ namespace YooAsset
|
||||||
InitManifest(manifest);
|
InitManifest(manifest);
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#region 解析资源清单辅助方法
|
#region 解析资源清单辅助方法
|
||||||
public static void InitManifest(PackageManifest manifest)
|
public static void InitManifest(PackageManifest manifest)
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace YooAsset
|
||||||
|
|
||||||
// 读取文件标记
|
// 读取文件标记
|
||||||
uint fileSign = _buffer.ReadUInt32();
|
uint fileSign = _buffer.ReadUInt32();
|
||||||
if (fileSign != YooAssetSettings.ManifestFileSign)
|
if (fileSign != ManifestDefine.FileSign)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
|
@ -67,11 +67,11 @@ namespace YooAsset
|
||||||
|
|
||||||
// 读取文件版本
|
// 读取文件版本
|
||||||
string fileVersion = _buffer.ReadUTF8();
|
string fileVersion = _buffer.ReadUTF8();
|
||||||
if (fileVersion != YooAssetSettings.ManifestFileVersion)
|
if (fileVersion != ManifestDefine.FileVersion)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.ManifestFileVersion}";
|
Error = $"The manifest file version are not compatible : {fileVersion} != {ManifestDefine.FileVersion}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,22 +16,6 @@ namespace YooAsset
|
||||||
public string PackageManifestPrefix = string.Empty;
|
public string PackageManifestPrefix = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清单文件头标记
|
|
||||||
/// </summary>
|
|
||||||
public const uint ManifestFileSign = 0x594F4F;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清单文件极限大小(100MB)
|
|
||||||
/// </summary>
|
|
||||||
public const int ManifestFileMaxSize = 104857600;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清单文件格式版本
|
|
||||||
/// </summary>
|
|
||||||
public const string ManifestFileVersion = "2.3.1";
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出文件夹名称
|
/// 构建输出文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -106,28 +106,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 路径相关
|
#region 路径相关
|
||||||
/// <summary>
|
|
||||||
/// 获取YOO的Resources目录的加载路径
|
|
||||||
/// </summary>
|
|
||||||
internal static string GetYooResourcesLoadPath(string packageName, string fileName)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
|
|
||||||
return PathUtility.Combine(packageName, fileName);
|
|
||||||
else
|
|
||||||
return PathUtility.Combine(Setting.DefaultYooFolderName, packageName, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取YOO的Resources目录的全路径
|
|
||||||
/// </summary>
|
|
||||||
internal static string GetYooResourcesFullPath()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
|
|
||||||
return $"Assets/Resources";
|
|
||||||
else
|
|
||||||
return $"Assets/Resources/{Setting.DefaultYooFolderName}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取YOO的编辑器下缓存文件根目录
|
/// 获取YOO的编辑器下缓存文件根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -17,7 +17,7 @@ internal class WXFSClearUnusedBundleFilesAsync : FSClearCacheFilesOperation
|
||||||
|
|
||||||
private readonly WechatFileSystem _fileSystem;
|
private readonly WechatFileSystem _fileSystem;
|
||||||
private readonly PackageManifest _manifest;
|
private readonly PackageManifest _manifest;
|
||||||
private List<string> _unusedCacheFiles;
|
private List<string> _unusedCacheFiles = new List<string>(1000);
|
||||||
private int _unusedFileTotalCount = 0;
|
private int _unusedFileTotalCount = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "2.3.4-preview",
|
"version": "2.3.5-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
Loading…
Reference in New Issue