mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-30 13:38:46 +00:00
Compare commits
1 Commits
2.3.5-prev
...
36f5770906
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36f5770906 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -20,8 +20,6 @@
|
|||||||
/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
|
||||||
|
|
||||||
|
|
||||||
@@ -74,4 +72,6 @@ sysinfo.txt
|
|||||||
# Crashlytics generated file
|
# Crashlytics generated file
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
|
|
||||||
*.vsconfig
|
*.vsconfig
|
||||||
|
Assets/csc.rsp
|
||||||
|
Assets/csc.rsp.meta
|
||||||
|
|||||||
@@ -2,15 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
## [2.3.5-preview] - 2025-03-14
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- (#502) 修复了原生缓存文件由于文件格式变动导致的加载本地缓存文件失败的问题。
|
|
||||||
- (#504) 修复了MacOS平台Offline Play Mode模式请求本地资源清单失败的问题。
|
|
||||||
- (#506) 修复了v2.3x版本LoadAllAssets方法计算依赖Bundle不完整的问题。
|
|
||||||
- (#506) 修复了微信小游戏文件系统,在启用加密算法后卸载bundle报错的问题。
|
|
||||||
|
|
||||||
## [2.3.4-preview] - 2025-03-08
|
## [2.3.4-preview] - 2025-03-08
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
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",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a61e5c2ca04aab647b1ed0492086aa8f
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
[InitializeOnLoad]
|
|
||||||
public class MacroProcessor : AssetPostprocessor
|
|
||||||
{
|
|
||||||
static string OnGeneratedCSProject(string path, string content)
|
|
||||||
{
|
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
|
||||||
xmlDoc.LoadXml(content);
|
|
||||||
|
|
||||||
if (IsCSProjectReferenced(xmlDoc.DocumentElement) == false)
|
|
||||||
return content;
|
|
||||||
|
|
||||||
if (ProcessDefineConstants(xmlDoc.DocumentElement) == false)
|
|
||||||
return content;
|
|
||||||
|
|
||||||
// 将修改后的XML结构重新输出为文本
|
|
||||||
var stringWriter = new StringWriter();
|
|
||||||
var writerSettings = new XmlWriterSettings();
|
|
||||||
writerSettings.Indent = true;
|
|
||||||
var xmlWriter = XmlWriter.Create(stringWriter, writerSettings);
|
|
||||||
xmlDoc.WriteTo(xmlWriter);
|
|
||||||
xmlWriter.Flush();
|
|
||||||
return stringWriter.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 处理宏定义
|
|
||||||
/// </summary>
|
|
||||||
private static bool ProcessDefineConstants(XmlElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool processed = false;
|
|
||||||
foreach (XmlNode node in element.ChildNodes)
|
|
||||||
{
|
|
||||||
if (node.Name != "PropertyGroup")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (XmlNode childNode in node.ChildNodes)
|
|
||||||
{
|
|
||||||
if (childNode.Name != "DefineConstants")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
string[] defines = childNode.InnerText.Split(';');
|
|
||||||
HashSet<string> hashSets = new HashSet<string>(defines);
|
|
||||||
foreach (string yooMacro in MacroDefine.Macros)
|
|
||||||
{
|
|
||||||
string tmpMacro = yooMacro.Trim();
|
|
||||||
if (hashSets.Contains(tmpMacro) == false)
|
|
||||||
hashSets.Add(tmpMacro);
|
|
||||||
}
|
|
||||||
childNode.InnerText = string.Join(";", hashSets.ToArray());
|
|
||||||
processed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检测工程是否引用了YooAsset
|
|
||||||
/// </summary>
|
|
||||||
private static bool IsCSProjectReferenced(XmlElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
foreach (XmlNode node in element.ChildNodes)
|
|
||||||
{
|
|
||||||
if (node.Name != "ItemGroup")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (XmlNode childNode in node.ChildNodes)
|
|
||||||
{
|
|
||||||
if (childNode.Name != "Reference" && childNode.Name != "ProjectReference")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
string include = childNode.Attributes["Include"].Value;
|
|
||||||
if (include.Contains("YooAsset"))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
214
Assets/YooAsset/Editor/Assembly/MacrosProcessor.cs
Normal file
214
Assets/YooAsset/Editor/Assembly/MacrosProcessor.cs
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.PackageManager;
|
||||||
|
using UnityEngine;
|
||||||
|
using static UnityEditor.PlayerSettings;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class MacrosProcessor : AssetPostprocessor
|
||||||
|
{
|
||||||
|
// csc.rsp 文件路径
|
||||||
|
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
|
||||||
|
/// <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 MacrosProcessor()
|
||||||
|
{
|
||||||
|
//添加到全局宏定义
|
||||||
|
UpdateRspFile(YooAssetMacros);
|
||||||
|
}
|
||||||
|
|
||||||
|
static string OnGeneratedCSProject(string path, string content)
|
||||||
|
{
|
||||||
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
xmlDoc.LoadXml(content);
|
||||||
|
|
||||||
|
if (IsCSProjectReferenced(xmlDoc.DocumentElement) == false)
|
||||||
|
return content;
|
||||||
|
|
||||||
|
if (ProcessDefineConstants(xmlDoc.DocumentElement) == false)
|
||||||
|
return content;
|
||||||
|
|
||||||
|
// 将修改后的XML结构重新输出为文本
|
||||||
|
var stringWriter = new StringWriter();
|
||||||
|
var writerSettings = new XmlWriterSettings();
|
||||||
|
writerSettings.Indent = true;
|
||||||
|
var xmlWriter = XmlWriter.Create(stringWriter, writerSettings);
|
||||||
|
xmlDoc.WriteTo(xmlWriter);
|
||||||
|
xmlWriter.Flush();
|
||||||
|
return stringWriter.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理宏定义
|
||||||
|
/// </summary>
|
||||||
|
private static bool ProcessDefineConstants(XmlElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool processed = false;
|
||||||
|
foreach (XmlNode node in element.ChildNodes)
|
||||||
|
{
|
||||||
|
if (node.Name != "PropertyGroup")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
{
|
||||||
|
if (childNode.Name != "DefineConstants")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string[] defines = childNode.InnerText.Split(';');
|
||||||
|
HashSet<string> hashSets = new HashSet<string>(defines);
|
||||||
|
foreach (string yooMacro in YooAssetMacros)
|
||||||
|
{
|
||||||
|
string tmpMacro = yooMacro.Trim();
|
||||||
|
if (hashSets.Contains(tmpMacro) == false)
|
||||||
|
hashSets.Add(tmpMacro);
|
||||||
|
}
|
||||||
|
childNode.InnerText = string.Join(";", hashSets.ToArray());
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测工程是否引用了YooAsset
|
||||||
|
/// </summary>
|
||||||
|
private static bool IsCSProjectReferenced(XmlElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (XmlNode node in element.ChildNodes)
|
||||||
|
{
|
||||||
|
if (node.Name != "ItemGroup")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
{
|
||||||
|
if (childNode.Name != "Reference" && childNode.Name != "ProjectReference")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string include = childNode.Attributes["Include"].Value;
|
||||||
|
if (include.Contains("YooAsset"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 更新csc.rsp文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="macrosToAdd"></param>
|
||||||
|
/// <param name="macrosToRemove"></param>
|
||||||
|
private static void UpdateRspFile(List<string> macrosToAdd = null, List<string> macrosToRemove = null)
|
||||||
|
{
|
||||||
|
HashSet<string> existingDefines = new HashSet<string>();
|
||||||
|
List<string> otherLines = new List<string>();
|
||||||
|
// 1. 读取现有内容
|
||||||
|
ReadRspFile(ref existingDefines, ref otherLines);
|
||||||
|
// 2. 添加新宏
|
||||||
|
if (macrosToAdd != null && macrosToAdd.Count > 0)
|
||||||
|
{
|
||||||
|
macrosToAdd.ForEach(x =>
|
||||||
|
{
|
||||||
|
if (existingDefines.Contains(x) == false)
|
||||||
|
existingDefines.Add(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 3. 移除指定宏
|
||||||
|
if (macrosToRemove != null && macrosToRemove.Count > 0)
|
||||||
|
{
|
||||||
|
macrosToRemove.ForEach(x =>
|
||||||
|
{
|
||||||
|
existingDefines.Remove(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 4. 重新生成内容
|
||||||
|
WriteRspFile(existingDefines, otherLines);
|
||||||
|
// 5. 刷新AssetDatabase
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.RequestScriptReload();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 读取csc.rsp文件,返回宏定义和其他行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="defines"></param>
|
||||||
|
/// <param name="others"></param>
|
||||||
|
private static void ReadRspFile(ref HashSet<string> defines, ref 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>
|
||||||
|
/// <param name="defines"></param>
|
||||||
|
/// <param name="others"></param>
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c2662e1d33b1eea469695b68d18b1739
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -37,9 +37,7 @@ namespace YooAsset
|
|||||||
string url;
|
string url;
|
||||||
|
|
||||||
// 获取对应平台的URL地址
|
// 获取对应平台的URL地址
|
||||||
#if UNITY_EDITOR_OSX
|
#if UNITY_EDITOR
|
||||||
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;
|
||||||
|
|||||||
@@ -333,13 +333,6 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -391,10 +384,10 @@ namespace YooAsset
|
|||||||
|
|
||||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element) == false)
|
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||||
return EFileVerifyResult.CacheNotFound;
|
return EFileVerifyResult.CacheNotFound;
|
||||||
|
|
||||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, EFileVerifyLevel.High);
|
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
||||||
@@ -434,10 +427,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement element))
|
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||||
{
|
{
|
||||||
_records.Remove(bundleGUID);
|
try
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RecordFileElement
|
internal class RecordFileElement
|
||||||
@@ -9,7 +7,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;
|
||||||
@@ -17,31 +15,5 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -261,30 +260,9 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_fileSystem.Exists(_bundle))
|
if (_fileSystem.Exists(_bundle))
|
||||||
{
|
{
|
||||||
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
|
DownloadProgress = 1f;
|
||||||
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
|
DownloadedBytes = _bundle.FileSize;
|
||||||
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
_steps = ESteps.LoadCacheRawBundle;
|
||||||
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,10 +7,9 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CheckManifest,
|
|
||||||
CheckArgs,
|
CheckArgs,
|
||||||
GetClearCacheFiles,
|
GetTagsCacheFiles,
|
||||||
ClearFilterCacheFiles,
|
ClearTagsCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,27 +29,13 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckManifest;
|
_steps = ESteps.CheckArgs;
|
||||||
}
|
}
|
||||||
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)
|
||||||
@@ -82,17 +67,17 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.GetClearCacheFiles;
|
_steps = ESteps.GetTagsCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetClearCacheFiles)
|
if (_steps == ESteps.GetTagsCacheFiles)
|
||||||
{
|
{
|
||||||
_clearBundleGUIDs = GetBundleGUIDsByTag();
|
_clearBundleGUIDs = GetTagsBundleGUIDs();
|
||||||
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearFilterCacheFiles;
|
_steps = ESteps.ClearTagsCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearFilterCacheFiles)
|
if (_steps == ESteps.ClearTagsCacheFiles)
|
||||||
{
|
{
|
||||||
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@@ -115,7 +100,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetBundleGUIDsByTag()
|
private List<string> GetTagsBundleGUIDs()
|
||||||
{
|
{
|
||||||
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,7 +8,6 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CheckManifest,
|
|
||||||
GetUnusedCacheFiles,
|
GetUnusedCacheFiles,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
@@ -20,7 +19,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;
|
||||||
@@ -28,29 +27,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckManifest;
|
_steps = ESteps.GetUnusedCacheFiles;
|
||||||
}
|
}
|
||||||
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,7 +8,6 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CheckManifest,
|
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
@@ -25,27 +24,13 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckManifest;
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|||||||
@@ -85,17 +85,15 @@ 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);
|
||||||
|
|||||||
@@ -83,6 +83,6 @@ namespace YooAsset
|
|||||||
/// 文件系统初始化参数列表
|
/// 文件系统初始化参数列表
|
||||||
/// 注意:列表最后一个元素作为主文件系统!
|
/// 注意:列表最后一个元素作为主文件系统!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<FileSystemParameters> FileSystemParameterList = new List<FileSystemParameters>();
|
public List<FileSystemParameters> FileSystemParameterList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,6 @@ 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;
|
||||||
|
|
||||||
@@ -31,11 +21,6 @@ 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>
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取依赖列表
|
/// 获取资源依赖列表
|
||||||
/// 注意:传入的资源对象一定合法有效!
|
/// 注意:传入的资源对象一定合法有效!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
|
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
|
||||||
@@ -188,21 +188,6 @@ 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>
|
||||||
|
|||||||
@@ -176,17 +176,7 @@ namespace YooAsset
|
|||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
PackageBundle[] depends;
|
var depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -263,7 +263,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(false);
|
DebugCheckInitialize();
|
||||||
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 +276,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(false);
|
DebugCheckInitialize();
|
||||||
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,7 +610,6 @@ 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)
|
||||||
@@ -721,7 +720,6 @@ 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();
|
||||||
@@ -831,7 +829,6 @@ 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();
|
||||||
@@ -941,7 +938,6 @@ 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();
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_assetBundle != null)
|
if (_assetBundle != null)
|
||||||
{
|
{
|
||||||
if (_packageBundle.Encrypted)
|
_assetBundle.TTUnload(true);
|
||||||
_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,10 +23,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_assetBundle != null)
|
if (_assetBundle != null)
|
||||||
{
|
{
|
||||||
if (_packageBundle.Encrypted)
|
_assetBundle.WXUnload(true);
|
||||||
_assetBundle.Unload(true);
|
|
||||||
else
|
|
||||||
_assetBundle.WXUnload(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string GetBundleFilePath()
|
public override string GetBundleFilePath()
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ 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;
|
||||||
|
|
||||||
@@ -228,7 +231,6 @@ public class WebFileStreamDecryption : 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);
|
||||||
|
|
||||||
@@ -240,15 +242,5 @@ 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.5-preview",
|
"version": "2.3.4-preview",
|
||||||
"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