mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
37 Commits
2.3.4-prev
...
2.3.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fb7f8bbfe | ||
|
|
b0382afad0 | ||
|
|
1ab7689174 | ||
|
|
29d456c065 | ||
|
|
b0dc829b04 | ||
|
|
b3ead90832 | ||
|
|
7bf00d4ff6 | ||
|
|
030e94d8ff | ||
|
|
cf05254121 | ||
|
|
3f786bca3b | ||
|
|
98719d212f | ||
|
|
3409f7ce4d | ||
|
|
f57b354e9b | ||
|
|
974493f88d | ||
|
|
69a69988a1 | ||
|
|
4e9c1955eb | ||
|
|
b6c68a533e | ||
|
|
38aa1c3509 | ||
|
|
eb2f783417 | ||
|
|
8556e071fa | ||
|
|
6155256fb6 | ||
|
|
0d4f2bc893 | ||
|
|
600e928ab4 | ||
|
|
4599ff098c | ||
|
|
4d2df5b705 | ||
|
|
79a7732cfd | ||
|
|
79467bbf13 | ||
|
|
c7d678282b | ||
|
|
d376afc217 | ||
|
|
a62f808591 | ||
|
|
b334a4986b | ||
|
|
a4111349a0 | ||
|
|
bdcf95384f | ||
|
|
d910af589d | ||
|
|
0531864534 | ||
|
|
72b1278f5c | ||
|
|
875cd24cba |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,6 +20,8 @@
|
|||||||
/Assets/StreamingAssets.meta
|
/Assets/StreamingAssets.meta
|
||||||
/Assets/Samples
|
/Assets/Samples
|
||||||
/Assets/Samples.meta
|
/Assets/Samples.meta
|
||||||
|
/Assets/csc.rsp
|
||||||
|
/Assets/csc.rsp.meta
|
||||||
/UserSettings
|
/UserSettings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,82 @@
|
|||||||
|
|
||||||
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.7] - 2025-04-01
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- (#526) 运行时资源清单的哈希值验证兼容了MD5和CRC32两种方式。
|
||||||
|
- (#515) 优化了资源路径大小写不敏感的逻辑代码,减少字符串操作产生的GC。
|
||||||
|
- (#523) UnloadUnusedAssetsOperation方法支持了分帧处理。
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#520) 修复了UWP平台获取WWW加载路径未适配的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了文件系统初始化参数:INSTALL_CLEAR_MODE
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 覆盖安装清理模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EOverwriteInstallClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不做任何处理
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||||
|
/// </summary>
|
||||||
|
ClearAllCacheFiles = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的清单文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllManifestFiles = 3,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增了初始化参数:BundleLoadingMaxConcurrency
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public abstract class InitializeParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同时加载Bundle文件的最大并发数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## [2.3.6] - 2025-03-25
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 构建管线新增了TaskCreateCatalog任务节点。
|
||||||
|
- 内置文件系统的catalog文件现在存储在streammingAssets目录下。
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#486) 修复了微信小游戏文件系统调用ClearUnusedBundleFiles时候的异常。
|
||||||
|
|
||||||
|
## [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
|
||||||
|
|||||||
17
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
17
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class MacroDefine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// YooAsset版本宏定义
|
||||||
|
/// </summary>
|
||||||
|
public static readonly List<string> Macros = new List<string>()
|
||||||
|
{
|
||||||
|
"YOO_ASSET_2",
|
||||||
|
"YOO_ASSET_2_3",
|
||||||
|
"YOO_ASSET_2_3_OR_NEWER",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/Assembly/MacroDefine.cs.meta
Normal file
11
Assets/YooAsset/Editor/Assembly/MacroDefine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a61e5c2ca04aab647b1ed0492086aa8f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,28 +1,15 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[InitializeOnLoad]
|
[InitializeOnLoad]
|
||||||
public class MacrosProcessor : AssetPostprocessor
|
public class MacroProcessor : AssetPostprocessor
|
||||||
{
|
{
|
||||||
static MacrosProcessor()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// YooAsset版本宏定义
|
|
||||||
/// </summary>
|
|
||||||
private static readonly List<string> YooAssetMacros = new List<string>()
|
|
||||||
{
|
|
||||||
"YOO_ASSET_2",
|
|
||||||
"YOO_ASSET_2_3",
|
|
||||||
"YOO_ASSET_2_3_OR_NEWER",
|
|
||||||
};
|
|
||||||
|
|
||||||
static string OnGeneratedCSProject(string path, string content)
|
static string OnGeneratedCSProject(string path, string content)
|
||||||
{
|
{
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
@@ -65,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
string[] defines = childNode.InnerText.Split(';');
|
string[] defines = childNode.InnerText.Split(';');
|
||||||
HashSet<string> hashSets = new HashSet<string>(defines);
|
HashSet<string> hashSets = new HashSet<string>(defines);
|
||||||
foreach (string yooMacro in YooAssetMacros)
|
foreach (string yooMacro in MacroDefine.Macros)
|
||||||
{
|
{
|
||||||
string tmpMacro = yooMacro.Trim();
|
string tmpMacro = yooMacro.Trim();
|
||||||
if (hashSets.Contains(tmpMacro) == false)
|
if (hashSets.Contains(tmpMacro) == false)
|
||||||
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#if YOO_ASSET_EXPERIMENT
|
||||||
|
namespace YooAsset.Editor.Experiment
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class RspGenerator
|
||||||
|
{
|
||||||
|
// csc.rsp文件路径
|
||||||
|
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
|
||||||
|
|
||||||
|
static RspGenerator()
|
||||||
|
{
|
||||||
|
UpdateRspFile(MacroDefine.Macros, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新csc.rsp文件
|
||||||
|
/// </summary>
|
||||||
|
private static void UpdateRspFile(List<string> addMacros, List<string> removeMacros)
|
||||||
|
{
|
||||||
|
var existingDefines = new HashSet<string>();
|
||||||
|
var otherLines = new List<string>();
|
||||||
|
|
||||||
|
// 1. 读取现有内容
|
||||||
|
ReadRspFile(existingDefines, otherLines);
|
||||||
|
|
||||||
|
// 2. 添加新宏
|
||||||
|
if (addMacros != null && addMacros.Count > 0)
|
||||||
|
{
|
||||||
|
addMacros.ForEach(x =>
|
||||||
|
{
|
||||||
|
if (existingDefines.Contains(x) == false)
|
||||||
|
existingDefines.Add(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 移除指定宏
|
||||||
|
if (removeMacros != null && removeMacros.Count > 0)
|
||||||
|
{
|
||||||
|
removeMacros.ForEach(x =>
|
||||||
|
{
|
||||||
|
existingDefines.Remove(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 重新生成内容
|
||||||
|
WriteRspFile(existingDefines, otherLines);
|
||||||
|
|
||||||
|
// 5. 刷新AssetDatabase
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.RequestScriptReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取csc.rsp文件,返回宏定义和其他行
|
||||||
|
/// </summary>
|
||||||
|
private static void ReadRspFile(HashSet<string> defines, List<string> others)
|
||||||
|
{
|
||||||
|
if (defines == null)
|
||||||
|
defines = new HashSet<string>();
|
||||||
|
|
||||||
|
if (others == null)
|
||||||
|
others = new List<string>();
|
||||||
|
|
||||||
|
if (File.Exists(RspFilePath) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (string line in File.ReadAllLines(RspFilePath))
|
||||||
|
{
|
||||||
|
if (line.StartsWith("-define:"))
|
||||||
|
{
|
||||||
|
string[] parts = line.Split(new[] { ':' }, 2);
|
||||||
|
if (parts.Length == 2)
|
||||||
|
{
|
||||||
|
defines.Add(parts[1].Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
others.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重新写入csc.rsp文件
|
||||||
|
/// </summary>
|
||||||
|
private static void WriteRspFile(HashSet<string> defines, List<string> others)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (others != null && others.Count > 0)
|
||||||
|
{
|
||||||
|
others.ForEach(o => sb.AppendLine(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defines != null && defines.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (string define in defines)
|
||||||
|
{
|
||||||
|
sb.AppendLine($"-define:{define}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(RspFilePath, sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
11
Assets/YooAsset/Editor/Assembly/RspGenerator.cs.meta
Normal file
11
Assets/YooAsset/Editor/Assembly/RspGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c2662e1d33b1eea469695b68d18b1739
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略的文件类型
|
/// 忽略的文件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ namespace YooAsset
|
|||||||
string url;
|
string url;
|
||||||
|
|
||||||
// 获取对应平台的URL地址
|
// 获取对应平台的URL地址
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR_OSX
|
||||||
|
url = StringUtility.Format("file://{0}", path);
|
||||||
|
#elif UNITY_EDITOR
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
#elif UNITY_WEBGL
|
#elif UNITY_WEBGL
|
||||||
url = path;
|
url = path;
|
||||||
@@ -65,7 +67,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#elif UNITY_STANDALONE_OSX
|
#elif UNITY_STANDALONE_OSX
|
||||||
url = new System.Uri(path).ToString();
|
url = new System.Uri(path).ToString();
|
||||||
#elif UNITY_STANDALONE
|
#elif UNITY_STANDALONE || UNITY_WSA
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
#else
|
#else
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -145,6 +150,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = Convert.ToBoolean(value);
|
AppendFileExtension = Convert.ToBoolean(value);
|
||||||
@@ -184,6 +193,7 @@ namespace YooAsset
|
|||||||
_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.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||||
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||||
_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.OnCreate(packageName, null);
|
_unpackFileSystem.OnCreate(packageName, null);
|
||||||
@@ -336,10 +346,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -188,6 +193,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = Convert.ToBoolean(value);
|
AppendFileExtension = Convert.ToBoolean(value);
|
||||||
@@ -227,8 +236,8 @@ namespace YooAsset
|
|||||||
_packageRoot = packageRoot;
|
_packageRoot = packageRoot;
|
||||||
|
|
||||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
||||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
|
||||||
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||||
|
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||||
}
|
}
|
||||||
public virtual void OnDestroy()
|
public virtual void OnDestroy()
|
||||||
{
|
{
|
||||||
@@ -333,6 +342,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 +400,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,22 +443,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))
|
||||||
{
|
{
|
||||||
try
|
_records.Remove(bundleGUID);
|
||||||
{
|
return element.DeleteFolder();
|
||||||
string dataFilePath = wrapper.DataFilePath;
|
|
||||||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
|
||||||
if (fileInfo.Exists)
|
|
||||||
fileInfo.Directory.Delete(true);
|
|
||||||
_records.Remove(bundleGUID);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -505,7 +509,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除所有清单文件
|
/// 删除所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteAllBundleFiles()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_cacheBundleFilesRoot))
|
||||||
|
{
|
||||||
|
Directory.Delete(_cacheBundleFilesRoot, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有缓存的清单文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DeleteAllManifestFiles()
|
public void DeleteAllManifestFiles()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 覆盖安装清理模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EOverwriteInstallClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不做任何处理
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||||
|
/// </summary>
|
||||||
|
ClearAllCacheFiles = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的清单文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllManifestFiles = 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c61fdc079dca97548a0158b8100ec258
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RecordFileElement
|
internal class RecordFileElement
|
||||||
@@ -7,7 +9,7 @@ namespace YooAsset
|
|||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string DataFileCRC { private set; get; }
|
public string 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, string dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
InfoFilePath = infoFilePath;
|
InfoFilePath = infoFilePath;
|
||||||
@@ -15,5 +17,31 @@ namespace YooAsset
|
|||||||
DataFileCRC = dataFileCRC;
|
DataFileCRC = dataFileCRC;
|
||||||
DataFileSize = dataFileSize;
|
DataFileSize = dataFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除记录文件
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteFolder()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(InfoFilePath);
|
||||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(directory);
|
||||||
|
if (directoryInfo.Exists)
|
||||||
|
{
|
||||||
|
directoryInfo.Delete(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,9 +46,32 @@ namespace YooAsset
|
|||||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||||
if (appFootPrint.IsDirty())
|
if (appFootPrint.IsDirty())
|
||||||
{
|
{
|
||||||
_fileSystem.DeleteAllManifestFiles();
|
if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.None)
|
||||||
|
{
|
||||||
|
YooLogger.Warning("Do nothing when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllCacheFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllBundleFiles();
|
||||||
|
_fileSystem.DeleteAllManifestFiles();
|
||||||
|
YooLogger.Warning("Delete all cache files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllBundleFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllBundleFiles();
|
||||||
|
YooLogger.Warning("Delete all bundle files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllManifestFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllManifestFiles();
|
||||||
|
YooLogger.Warning("Delete all manifest files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(_fileSystem.InstallClearMode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
appFootPrint.Coverage(_fileSystem.PackageName);
|
appFootPrint.Coverage(_fileSystem.PackageName);
|
||||||
YooLogger.Warning("Delete manifest files when application foot print dirty !");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.SearchCacheFiles;
|
_steps = ESteps.SearchCacheFiles;
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
CheckArgs,
|
CheckArgs,
|
||||||
GetTagsCacheFiles,
|
GetClearCacheFiles,
|
||||||
ClearTagsCacheFiles,
|
ClearFilterCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,13 +30,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckArgs;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
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.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckArgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckArgs)
|
if (_steps == ESteps.CheckArgs)
|
||||||
{
|
{
|
||||||
if (_clearParam == null)
|
if (_clearParam == null)
|
||||||
@@ -67,17 +82,17 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.GetTagsCacheFiles;
|
_steps = ESteps.GetClearCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetTagsCacheFiles)
|
if (_steps == ESteps.GetClearCacheFiles)
|
||||||
{
|
{
|
||||||
_clearBundleGUIDs = GetTagsBundleGUIDs();
|
_clearBundleGUIDs = GetBundleGUIDsByTag();
|
||||||
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearTagsCacheFiles;
|
_steps = ESteps.ClearFilterCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearTagsCacheFiles)
|
if (_steps == ESteps.ClearFilterCacheFiles)
|
||||||
{
|
{
|
||||||
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@@ -100,7 +115,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetTagsBundleGUIDs()
|
private List<string> GetBundleGUIDsByTag()
|
||||||
{
|
{
|
||||||
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
||||||
List<string> result = new List<string>(allBundleGUIDs.Count);
|
List<string> result = new List<string>(allBundleGUIDs.Count);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
GetUnusedCacheFiles,
|
GetUnusedCacheFiles,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
@@ -19,7 +20,7 @@ namespace YooAsset
|
|||||||
private int _unusedFileTotalCount = 0;
|
private int _unusedFileTotalCount = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal ClearUnusedCacheBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
|
internal ClearUnusedCacheBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
@@ -27,15 +28,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.GetUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
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.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.GetUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetUnusedCacheFiles)
|
if (_steps == ESteps.GetUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
||||||
_unusedFileTotalCount = _unusedBundleGUIDs.Count;
|
_unusedFileTotalCount = _unusedBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearUnusedCacheFiles;
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
@@ -24,13 +25,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.ClearUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
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.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearUnusedCacheFiles)
|
if (_steps == ESteps.ClearUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,15 +85,17 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 创建验证元素类
|
// 创建验证元素类
|
||||||
string fileRootPath = chidDirectory.FullName;
|
string fileRootPath = chidDirectory.FullName;
|
||||||
string dataFilePath = $"{fileRootPath}/{ DefaultCacheFileSystemDefine.BundleDataFileName}";
|
string dataFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleDataFileName}";
|
||||||
string infoFilePath = $"{fileRootPath}/{ DefaultCacheFileSystemDefine.BundleInfoFileName}";
|
string infoFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleInfoFileName}";
|
||||||
|
|
||||||
// 存储的数据文件追加文件格式
|
// 存储的数据文件追加文件格式
|
||||||
if (_fileSystem.AppendFileExtension)
|
if (_fileSystem.AppendFileExtension)
|
||||||
{
|
{
|
||||||
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||||
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||||
|
{
|
||||||
dataFilePath += dataFileExtension;
|
dataFilePath += dataFileExtension;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var element = new VerifyFileElement(_fileSystem.PackageName, bundleGUID, fileRootPath, dataFilePath, infoFilePath);
|
var element = new VerifyFileElement(_fileSystem.PackageName, bundleGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace YooAsset
|
|||||||
base.OnCreate(packageName, rootDirectory);
|
base.OnCreate(packageName, rootDirectory);
|
||||||
|
|
||||||
// 注意:重写保存根目录和临时目录
|
// 注意:重写保存根目录和临时目录
|
||||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveBundleFilesFolderName);
|
||||||
|
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveManifestFilesFolderName);
|
||||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,13 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存的资源文件的文件夹名称
|
/// 保存的资源文件的文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SaveFilesFolderName = "UnpackFiles";
|
public const string SaveBundleFilesFolderName = "UnpackBundleFiles";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存的清单文件的文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string SaveManifestFilesFolderName = "UnpackManifestFiles";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载的临时文件的文件夹名称
|
/// 下载的临时文件的文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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";
|
||||||
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InitializeParameters
|
public abstract class InitializeParameters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同时加载Bundle文件的最大并发数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -83,6 +87,6 @@ namespace YooAsset
|
|||||||
/// 文件系统初始化参数列表
|
/// 文件系统初始化参数列表
|
||||||
/// 注意:列表最后一个元素作为主文件系统!
|
/// 注意:列表最后一个元素作为主文件系统!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<FileSystemParameters> FileSystemParameterList;
|
public readonly List<FileSystemParameters> FileSystemParameterList = new List<FileSystemParameters>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,8 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadFile,
|
CheckConcurrency,
|
||||||
|
LoadBundleFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,17 +58,32 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.CheckConcurrency;
|
||||||
}
|
}
|
||||||
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.LoadFile)
|
if (_steps == ESteps.CheckConcurrency)
|
||||||
|
{
|
||||||
|
if (IsWaitForAsyncComplete)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadBundleFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_resourceManager.BundleLoadingIsBusy())
|
||||||
|
return;
|
||||||
|
_steps = ESteps.LoadBundleFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadBundleFile)
|
||||||
{
|
{
|
||||||
if (_loadBundleOp == null)
|
if (_loadBundleOp == null)
|
||||||
{
|
{
|
||||||
|
_resourceManager.BundleLoadingCounter++;
|
||||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||||
_loadBundleOp.StartOperation();
|
_loadBundleOp.StartOperation();
|
||||||
AddChildOperation(_loadBundleOp);
|
AddChildOperation(_loadBundleOp);
|
||||||
@@ -103,6 +119,9 @@ namespace YooAsset
|
|||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _loadBundleOp.Error;
|
Error = _loadBundleOp.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统计计数减少
|
||||||
|
_resourceManager.BundleLoadingCounter--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void InternalWaitForAsyncComplete()
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
private readonly ResourceManager _resManager;
|
private readonly ResourceManager _resManager;
|
||||||
private readonly int _loopCount;
|
private readonly int _loopCount;
|
||||||
|
private int _loopCounter = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
||||||
@@ -25,6 +26,7 @@ namespace YooAsset
|
|||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.UnloadUnused;
|
_steps = ESteps.UnloadUnused;
|
||||||
|
_loopCounter = _loopCount;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
@@ -33,13 +35,23 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.UnloadUnused)
|
if (_steps == ESteps.UnloadUnused)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _loopCount; i++)
|
while (_loopCounter > 0)
|
||||||
{
|
{
|
||||||
|
_loopCounter--;
|
||||||
LoopUnloadUnused();
|
LoopUnloadUnused();
|
||||||
|
|
||||||
|
if (IsWaitForAsyncComplete == false)
|
||||||
|
{
|
||||||
|
if (OperationSystem.IsBusy)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
if (_loopCounter <= 0)
|
||||||
Status = EOperationStatus.Succeed;
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void InternalWaitForAsyncComplete()
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace YooAsset
|
|||||||
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
|
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
|
||||||
private long _sceneCreateIndex = 0;
|
private long _sceneCreateIndex = 0;
|
||||||
private IBundleQuery _bundleQuery;
|
private IBundleQuery _bundleQuery;
|
||||||
|
private int _bundleLoadingMaxConcurrency;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属包裹
|
/// 所属包裹
|
||||||
@@ -25,6 +26,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LockLoadOperation = false;
|
public bool LockLoadOperation = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 统计正在加载的Bundle文件数量
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingCounter = 0;
|
||||||
|
|
||||||
|
|
||||||
public ResourceManager(string packageName)
|
public ResourceManager(string packageName)
|
||||||
{
|
{
|
||||||
@@ -34,8 +40,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化
|
/// 初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(IBundleQuery bundleServices)
|
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||||
{
|
{
|
||||||
|
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||||
_bundleQuery = bundleServices;
|
_bundleQuery = bundleServices;
|
||||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||||
}
|
}
|
||||||
@@ -310,6 +317,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return LoaderDic.Count > 0;
|
return LoaderDic.Count > 0;
|
||||||
}
|
}
|
||||||
|
internal bool BundleLoadingIsBusy()
|
||||||
|
{
|
||||||
|
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
|
||||||
|
}
|
||||||
|
|
||||||
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,16 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public class AssetInfo
|
public class AssetInfo
|
||||||
{
|
{
|
||||||
|
internal enum ELoadMethod
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
LoadAsset,
|
||||||
|
LoadSubAssets,
|
||||||
|
LoadAllAssets,
|
||||||
|
LoadScene,
|
||||||
|
LoadRawFile,
|
||||||
|
}
|
||||||
|
|
||||||
private readonly PackageAsset _packageAsset;
|
private readonly PackageAsset _packageAsset;
|
||||||
private string _providerGUID;
|
private string _providerGUID;
|
||||||
|
|
||||||
@@ -21,6 +31,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Error { private set; get; }
|
public string Error { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载方法
|
||||||
|
/// </summary>
|
||||||
|
internal ELoadMethod LoadMethod;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象
|
/// 资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
21
Assets/YooAsset/Runtime/ResourcePackage/ManifestDefine.cs
Normal file
21
Assets/YooAsset/Runtime/ResourcePackage/ManifestDefine.cs
Normal file
@@ -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,30 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal static class ManifestTools
|
internal static class ManifestTools
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
/// <summary>
|
||||||
|
/// 验证清单文件的二进制数据
|
||||||
|
/// </summary>
|
||||||
|
public static bool VerifyManifestData(byte[] fileData, string hashValue)
|
||||||
|
{
|
||||||
|
if (fileData == null || fileData.Length == 0)
|
||||||
|
return false;
|
||||||
|
if (string.IsNullOrEmpty(hashValue))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 注意:兼容俩种验证方式
|
||||||
|
// 注意:计算MD5的哈希值通常为32个字符
|
||||||
|
string fileHash;
|
||||||
|
if (hashValue.Length == 32)
|
||||||
|
fileHash = HashUtility.BytesMD5(fileData);
|
||||||
|
else
|
||||||
|
fileHash = HashUtility.BytesCRC32(fileData);
|
||||||
|
|
||||||
|
if (fileHash == hashValue)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化(JSON文件)
|
/// 序列化(JSON文件)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -26,10 +49,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 +120,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 +183,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)
|
||||||
@@ -198,9 +221,16 @@ namespace YooAsset
|
|||||||
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
|
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
|
||||||
|
|
||||||
if (manifest.EnableAddressable)
|
if (manifest.EnableAddressable)
|
||||||
|
{
|
||||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
|
{
|
||||||
|
if (manifest.LocationToLower)
|
||||||
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2, StringComparer.OrdinalIgnoreCase);
|
||||||
|
else
|
||||||
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (manifest.IncludeAssetGUID)
|
if (manifest.IncludeAssetGUID)
|
||||||
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
|
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
|
||||||
@@ -222,8 +252,6 @@ namespace YooAsset
|
|||||||
// 填充AssetPathMapping1
|
// 填充AssetPathMapping1
|
||||||
{
|
{
|
||||||
string location = packageAsset.AssetPath;
|
string location = packageAsset.AssetPath;
|
||||||
if (manifest.LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
// 添加原生路径的映射
|
// 添加原生路径的映射
|
||||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,9 +138,6 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(location))
|
if (string.IsNullOrEmpty(location))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
if (LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
return assetPath;
|
return assetPath;
|
||||||
else
|
else
|
||||||
@@ -174,7 +171,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源依赖列表
|
/// 获取依赖列表
|
||||||
/// 注意:传入的资源对象一定合法有效!
|
/// 注意:传入的资源对象一定合法有效!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
|
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
|
||||||
@@ -188,6 +185,21 @@ namespace YooAsset
|
|||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取依赖列表
|
||||||
|
/// 注意:传入的资源包对象一定合法有效!
|
||||||
|
/// </summary>
|
||||||
|
public PackageBundle[] GetAllDependencies(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
List<PackageBundle> result = new List<PackageBundle>(packageBundle.DependBundleIDs.Length);
|
||||||
|
foreach (var dependID in packageBundle.DependBundleIDs)
|
||||||
|
{
|
||||||
|
var dependBundle = GetMainPackageBundle(dependID);
|
||||||
|
result.Add(dependBundle);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 尝试获取包裹的资源
|
/// 尝试获取包裹的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -292,9 +304,6 @@ namespace YooAsset
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
{
|
{
|
||||||
return assetPath;
|
return assetPath;
|
||||||
|
|||||||
@@ -176,7 +176,17 @@ namespace YooAsset
|
|||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
|
PackageBundle[] depends;
|
||||||
|
if (assetInfo.LoadMethod == AssetInfo.ELoadMethod.LoadAllAssets)
|
||||||
|
{
|
||||||
|
var mainBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
|
||||||
|
depends = ActiveManifest.GetAllDependencies(mainBundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
|
||||||
|
}
|
||||||
|
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
|||||||
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
|
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
|
||||||
_bundleQuery = playModeImpl;
|
_bundleQuery = playModeImpl;
|
||||||
_playModeImpl = playModeImpl;
|
_playModeImpl = playModeImpl;
|
||||||
_resourceManager.Initialize(_bundleQuery);
|
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
InitializationOperation initializeOperation;
|
InitializationOperation initializeOperation;
|
||||||
@@ -162,6 +162,10 @@ namespace YooAsset
|
|||||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 检测初始化参数
|
||||||
|
if (parameters.BundleLoadingMaxConcurrency <= 0)
|
||||||
|
throw new Exception($"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
|
||||||
|
|
||||||
// 鉴定运行模式
|
// 鉴定运行模式
|
||||||
if (parameters is EditorSimulateModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
_playMode = EPlayMode.EditorSimulateMode;
|
_playMode = EPlayMode.EditorSimulateMode;
|
||||||
@@ -263,7 +267,7 @@ namespace YooAsset
|
|||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -276,7 +280,7 @@ namespace YooAsset
|
|||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -610,6 +614,7 @@ namespace YooAsset
|
|||||||
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
|
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
|
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadScene;
|
||||||
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
|
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
|
||||||
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
|
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
@@ -720,6 +725,7 @@ namespace YooAsset
|
|||||||
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
|
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAsset;
|
||||||
var handle = _resourceManager.LoadAssetAsync(assetInfo, priority);
|
var handle = _resourceManager.LoadAssetAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
@@ -829,6 +835,7 @@ namespace YooAsset
|
|||||||
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
|
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadSubAssets;
|
||||||
var handle = _resourceManager.LoadSubAssetsAsync(assetInfo, priority);
|
var handle = _resourceManager.LoadSubAssetsAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
@@ -938,6 +945,7 @@ namespace YooAsset
|
|||||||
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
|
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAllAssets;
|
||||||
var handle = _resourceManager.LoadAllAssetsAsync(assetInfo, priority);
|
var handle = _resourceManager.LoadAllAssetsAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_assetBundle != null)
|
if (_assetBundle != null)
|
||||||
{
|
{
|
||||||
_assetBundle.TTUnload(true);
|
if (_packageBundle.Encrypted)
|
||||||
|
_assetBundle.Unload(true);
|
||||||
|
else
|
||||||
|
_assetBundle.TTUnload(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string GetBundleFilePath()
|
public override string GetBundleFilePath()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly PackageBundle _packageBundle;
|
private readonly PackageBundle _packageBundle;
|
||||||
private readonly AssetBundle _assetBundle;
|
private readonly AssetBundle _assetBundle;
|
||||||
|
|
||||||
public WXAssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle)
|
public WXAssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
@@ -23,7 +23,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_assetBundle != null)
|
if (_assetBundle != null)
|
||||||
{
|
{
|
||||||
_assetBundle.WXUnload(true);
|
if (_packageBundle.Encrypted)
|
||||||
|
_assetBundle.Unload(true);
|
||||||
|
else
|
||||||
|
_assetBundle.WXUnload(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string GetBundleFilePath()
|
public override string GetBundleFilePath()
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class PatchWindow : MonoBehaviour
|
|||||||
{
|
{
|
||||||
UserEventDefine.UserTryRequestPackageVersion.SendEventMessage();
|
UserEventDefine.UserTryRequestPackageVersion.SendEventMessage();
|
||||||
};
|
};
|
||||||
ShowMessageBox($"Failed to update static version, please check the network status.", callback);
|
ShowMessageBox($"Failed to request package version, please check the network status.", callback);
|
||||||
}
|
}
|
||||||
else if (message is PatchEventDefine.PackageManifestUpdateFailed)
|
else if (message is PatchEventDefine.PackageManifestUpdateFailed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public static class TestPackageBuilder
|
|||||||
buildParameters.ClearBuildCacheFiles = true;
|
buildParameters.ClearBuildCacheFiles = true;
|
||||||
buildParameters.UseAssetDependencyDB = true;
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||||
|
|
||||||
var pipeline = new ScriptableBuildPipeline();
|
var pipeline = new ScriptableBuildPipeline();
|
||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
@@ -108,7 +108,7 @@ public static class TestPackageBuilder
|
|||||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||||
buildParameters.ClearBuildCacheFiles = true;
|
buildParameters.ClearBuildCacheFiles = true;
|
||||||
buildParameters.UseAssetDependencyDB = true;
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||||
|
|
||||||
var pipeline = new BuiltinBuildPipeline();
|
var pipeline = new BuiltinBuildPipeline();
|
||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new OfflinePlayModeParameters();
|
var initParams = new OfflinePlayModeParameters();
|
||||||
var decryption = new FileStreamDecryption();
|
var decryption = new FileStreamTestDecryption();
|
||||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(decryption, packageRoot);
|
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(decryption, packageRoot);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializeAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
using UnityEngine.U2D;
|
|
||||||
using UnityEngine.TestTools;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
@@ -37,7 +34,7 @@ public class TestBundleEncryption
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件流加密方式
|
/// 文件流加密方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileStreamEncryption : IEncryptionServices
|
public class FileStreamTestEncryption : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
@@ -67,7 +64,7 @@ public class FileStreamEncryption : IEncryptionServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件偏移加密方式
|
/// 文件偏移加密方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileOffsetEncryption : IEncryptionServices
|
public class FileOffsetTestEncryption : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
@@ -122,7 +119,7 @@ public class BundleStream : FileStream
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件流解密类
|
/// 资源文件流解密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileStreamDecryption : IDecryptionServices
|
public class FileStreamTestDecryption : IDecryptionServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步方式获取解密的资源包对象
|
/// 同步方式获取解密的资源包对象
|
||||||
@@ -175,7 +172,7 @@ public class FileStreamDecryption : IDecryptionServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件偏移解密类
|
/// 资源文件偏移解密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileOffsetDecryption : IDecryptionServices
|
public class FileOffsetTestDecryption : IDecryptionServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步方式获取解密的资源包对象
|
/// 同步方式获取解密的资源包对象
|
||||||
@@ -227,10 +224,11 @@ public class FileOffsetDecryption : IDecryptionServices
|
|||||||
/// WebGL平台解密类
|
/// WebGL平台解密类
|
||||||
/// 注意:WebGL平台支持内存解密
|
/// 注意:WebGL平台支持内存解密
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WebFileStreamDecryption : IWebDecryptionServices
|
public class WebFileStreamTestDecryption : IWebDecryptionServices
|
||||||
{
|
{
|
||||||
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
|
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
byte[] copyData = new byte[fileInfo.FileData.Length];
|
byte[] copyData = new byte[fileInfo.FileData.Length];
|
||||||
Buffer.BlockCopy(fileInfo.FileData, 0, copyData, 0, fileInfo.FileData.Length);
|
Buffer.BlockCopy(fileInfo.FileData, 0, copyData, 0, fileInfo.FileData.Length);
|
||||||
|
|
||||||
@@ -242,5 +240,15 @@ public class WebFileStreamDecryption : IWebDecryptionServices
|
|||||||
WebDecryptResult decryptResult = new WebDecryptResult();
|
WebDecryptResult decryptResult = new WebDecryptResult();
|
||||||
decryptResult.Result = AssetBundle.LoadFromMemory(copyData);
|
decryptResult.Result = AssetBundle.LoadFromMemory(copyData);
|
||||||
return decryptResult;
|
return decryptResult;
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (int i = 0; i < fileInfo.FileData.Length; i++)
|
||||||
|
{
|
||||||
|
fileInfo.FileData[i] ^= BundleStream.KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebDecryptResult decryptResult = new WebDecryptResult();
|
||||||
|
decryptResult.Result = AssetBundle.LoadFromMemory(fileInfo.FileData);
|
||||||
|
return decryptResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "2.3.4-preview",
|
"version": "2.3.7",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user