Compare commits

..

1 Commits

Author SHA1 Message Date
Y-way
8d746ca519 Merge bdcf95384f into b334a4986b 2025-03-12 13:41:36 +08:00
25 changed files with 271 additions and 459 deletions

6
.gitignore vendored
View File

@@ -20,8 +20,6 @@
/Assets/StreamingAssets.meta
/Assets/Samples
/Assets/Samples.meta
/Assets/csc.rsp
/Assets/csc.rsp.meta
/UserSettings
@@ -74,4 +72,6 @@ sysinfo.txt
# Crashlytics generated file
crashlytics-build.properties
*.vsconfig
*.vsconfig
Assets/csc.rsp
Assets/csc.rsp.meta

View File

@@ -2,15 +2,6 @@
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
### Improvements

View File

@@ -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",
};
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a61e5c2ca04aab647b1ed0492086aa8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View 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());
}
}
}

View File

@@ -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

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c2662e1d33b1eea469695b68d18b1739
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -333,13 +333,6 @@ namespace YooAsset
{
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)
{
@@ -391,10 +384,10 @@ namespace YooAsset
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;
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;
}
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
@@ -434,10 +427,22 @@ namespace YooAsset
}
public bool DeleteCacheBundleFile(string bundleGUID)
{
if (_records.TryGetValue(bundleGUID, out RecordFileElement element))
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
{
_records.Remove(bundleGUID);
return element.DeleteFolder();
try
{
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
{

View File

@@ -1,6 +1,4 @@
using System;
using System.IO;

namespace YooAsset
{
internal class RecordFileElement
@@ -9,7 +7,7 @@ namespace YooAsset
public string DataFilePath { private set; get; }
public string DataFileCRC { private set; get; }
public long DataFileSize { private set; get; }
public RecordFileElement(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
{
InfoFilePath = infoFilePath;
@@ -17,31 +15,5 @@ namespace YooAsset
DataFileCRC = dataFileCRC;
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;
}
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using UnityEngine;
namespace YooAsset
@@ -261,30 +260,9 @@ namespace YooAsset
{
if (_fileSystem.Exists(_bundle))
{
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
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;
}
DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize;
_steps = ESteps.LoadCacheRawBundle;
}
else
{

View File

@@ -7,10 +7,9 @@ namespace YooAsset
private enum ESteps
{
None,
CheckManifest,
CheckArgs,
GetClearCacheFiles,
ClearFilterCacheFiles,
GetTagsCacheFiles,
ClearTagsCacheFiles,
Done,
}
@@ -30,27 +29,13 @@ namespace YooAsset
}
internal override void InternalStart()
{
_steps = ESteps.CheckManifest;
_steps = ESteps.CheckArgs;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
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 (_clearParam == null)
@@ -82,17 +67,17 @@ namespace YooAsset
return;
}
_steps = ESteps.GetClearCacheFiles;
_steps = ESteps.GetTagsCacheFiles;
}
if (_steps == ESteps.GetClearCacheFiles)
if (_steps == ESteps.GetTagsCacheFiles)
{
_clearBundleGUIDs = GetBundleGUIDsByTag();
_clearBundleGUIDs = GetTagsBundleGUIDs();
_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--)
{
@@ -115,7 +100,7 @@ namespace YooAsset
}
}
}
private List<string> GetBundleGUIDsByTag()
private List<string> GetTagsBundleGUIDs()
{
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
List<string> result = new List<string>(allBundleGUIDs.Count);

View File

@@ -8,7 +8,6 @@ namespace YooAsset
private enum ESteps
{
None,
CheckManifest,
GetUnusedCacheFiles,
ClearUnusedCacheFiles,
Done,
@@ -20,7 +19,7 @@ namespace YooAsset
private int _unusedFileTotalCount = 0;
private ESteps _steps = ESteps.None;
internal ClearUnusedCacheBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
{
_fileSystem = fileSystem;
@@ -28,29 +27,15 @@ namespace YooAsset
}
internal override void InternalStart()
{
_steps = ESteps.CheckManifest;
_steps = ESteps.GetUnusedCacheFiles;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
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)
{
{
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
_unusedFileTotalCount = _unusedBundleGUIDs.Count;
_steps = ESteps.ClearUnusedCacheFiles;

View File

@@ -8,7 +8,6 @@ namespace YooAsset
private enum ESteps
{
None,
CheckManifest,
ClearUnusedCacheFiles,
Done,
}
@@ -25,27 +24,13 @@ namespace YooAsset
}
internal override void InternalStart()
{
_steps = ESteps.CheckManifest;
_steps = ESteps.ClearUnusedCacheFiles;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
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)
{
try

View File

@@ -92,7 +92,12 @@ namespace YooAsset
if (_fileSystem.AppendFileExtension)
{
string dataFileExtension = FindDataFileExtension(chidDirectory);
if (string.IsNullOrEmpty(dataFileExtension) == false)
if (string.IsNullOrEmpty(dataFileExtension))
{
//注意:覆盖安装的情况下,缓存文件可能会没有后缀格式,需要删除重新下载!
dataFilePath = string.Empty;
}
else
{
dataFilePath += dataFileExtension;
}

View File

@@ -83,6 +83,6 @@ namespace YooAsset
/// 文件系统初始化参数列表
/// 注意:列表最后一个元素作为主文件系统!
/// </summary>
public readonly List<FileSystemParameters> FileSystemParameterList = new List<FileSystemParameters>();
public List<FileSystemParameters> FileSystemParameterList;
}
}

View File

@@ -3,16 +3,6 @@ namespace YooAsset
{
public class AssetInfo
{
internal enum ELoadMethod
{
None = 0,
LoadAsset,
LoadSubAssets,
LoadAllAssets,
LoadScene,
LoadRawFile,
}
private readonly PackageAsset _packageAsset;
private string _providerGUID;
@@ -31,11 +21,6 @@ namespace YooAsset
/// </summary>
public string Error { private set; get; }
/// <summary>
/// 加载方法
/// </summary>
internal ELoadMethod LoadMethod;
/// <summary>
/// 资源对象
/// </summary>

View File

@@ -174,7 +174,7 @@ namespace YooAsset
}
/// <summary>
/// 获取依赖列表
/// 获取资源依赖列表
/// 注意:传入的资源对象一定合法有效!
/// </summary>
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
@@ -188,21 +188,6 @@ namespace YooAsset
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>

View File

@@ -176,17 +176,7 @@ namespace YooAsset
throw new Exception("Should never get here !");
// 注意:如果清单里未找到资源包会抛出异常!
PackageBundle[] depends;
if (assetInfo.LoadMethod == AssetInfo.ELoadMethod.LoadAllAssets)
{
var mainBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
depends = ActiveManifest.GetAllDependencies(mainBundle);
}
else
{
depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
}
var depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
foreach (var packageBundle in depends)
{

View File

@@ -263,7 +263,7 @@ namespace YooAsset
/// <param name="clearParam">执行参数</param>
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
{
DebugCheckInitialize(false);
DebugCheckInitialize();
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
OperationSystem.StartOperation(PackageName, operation);
return operation;
@@ -276,7 +276,7 @@ namespace YooAsset
/// <param name="clearParam">执行参数</param>
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
{
DebugCheckInitialize(false);
DebugCheckInitialize();
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
OperationSystem.StartOperation(PackageName, operation);
return operation;
@@ -610,7 +610,6 @@ namespace YooAsset
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
{
DebugCheckAssetLoadType(assetInfo.AssetType);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadScene;
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
if (waitForAsyncComplete)
@@ -721,7 +720,6 @@ namespace YooAsset
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadType(assetInfo.AssetType);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAsset;
var handle = _resourceManager.LoadAssetAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
@@ -831,7 +829,6 @@ namespace YooAsset
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadType(assetInfo.AssetType);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadSubAssets;
var handle = _resourceManager.LoadSubAssetsAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
@@ -941,7 +938,6 @@ namespace YooAsset
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadType(assetInfo.AssetType);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAllAssets;
var handle = _resourceManager.LoadAllAssetsAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();

View File

@@ -23,10 +23,7 @@ namespace YooAsset
{
if (_assetBundle != null)
{
if (_packageBundle.Encrypted)
_assetBundle.Unload(true);
else
_assetBundle.TTUnload(true);
_assetBundle.TTUnload(true);
}
}
public override string GetBundleFilePath()

View File

@@ -11,7 +11,7 @@ namespace YooAsset
private readonly IFileSystem _fileSystem;
private readonly PackageBundle _packageBundle;
private readonly AssetBundle _assetBundle;
public WXAssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle)
{
_fileSystem = fileSystem;
@@ -23,10 +23,7 @@ namespace YooAsset
{
if (_assetBundle != null)
{
if (_packageBundle.Encrypted)
_assetBundle.Unload(true);
else
_assetBundle.WXUnload(true);
_assetBundle.WXUnload(true);
}
}
public override string GetBundleFilePath()

View File

@@ -3,6 +3,9 @@ using System.IO;
using System.Text;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.U2D;
using UnityEngine.TestTools;
using NUnit.Framework;
using YooAsset;
@@ -228,7 +231,6 @@ public class WebFileStreamDecryption : IWebDecryptionServices
{
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
{
/*
byte[] copyData = new byte[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();
decryptResult.Result = AssetBundle.LoadFromMemory(copyData);
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;
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
"version": "2.3.5-preview",
"version": "2.3.4-preview",
"unity": "2019.4",
"description": "unity3d resources management system.",
"author": {