Compare commits

...

17 Commits
2.3.8 ... 2.3.9

Author SHA1 Message Date
何冠峰
eabebf3d8f Update CHANGELOG.md 2025-05-13 10:47:59 +08:00
何冠峰
4ef789520a Update package.json 2025-05-13 10:47:49 +08:00
何冠峰
4322f3c58c fix #545 2025-05-13 10:23:22 +08:00
何冠峰
c40a796170 fix #542 2025-05-13 10:11:06 +08:00
何冠峰
32841d4773 Update AssetBundleDebuggerWindow.cs 2025-05-09 15:29:26 +08:00
何冠峰
e469b32d94 refactor: The tag diffusion logic in the collector
优化收集器tag传染扩散逻辑,避免Group里配置了Tag导致的无意义的警告信息。
2025-04-23 18:42:26 +08:00
何冠峰
c0e5315953 feat : Buld the pipeline output the log file.
构建管线输出构建日志到输出目录下。
2025-04-23 18:19:13 +08:00
何冠峰
7b5f366533 Build system add BuiltinShadersBundleNameIsNull ErrorCode 2025-04-23 16:56:03 +08:00
何冠峰
e674d5bf97 update extension sample
PanelMonitor增加控制开关
2025-04-23 16:39:07 +08:00
何冠峰
9b0bebd981 refactor : Macro scripts control by YOO_ASSET_EXPERIMENT 2025-04-23 16:38:17 +08:00
何冠峰
dc46462bfa fix : remove Caching class
it's not support in webGL
2025-04-23 14:14:34 +08:00
何冠峰
51c9943cf2 修复了输出csproject工程文件编码为UTF16的问题
修正BOM问题
2025-04-22 17:41:36 +08:00
何冠峰
3db9b750e3 update logo 2025-04-22 16:47:44 +08:00
何冠峰
1b57a0b7df 修复了输出csproject工程文件编码为UTF16的问题。 2025-04-22 16:47:33 +08:00
何冠峰
bd5ce1e6bd perf : webgl platform use crc verify the bundle when first time downloaded
WebGL平台首次下载会验证CRC。
2025-04-18 18:21:24 +08:00
何冠峰
7eb74d4dd1 update extension sample 2025-04-18 17:11:40 +08:00
何冠峰
a384ca1f18 feat : scriptable build pipeline add StripUnityVersion parameter.
新增构建参数
2025-04-18 16:48:03 +08:00
17 changed files with 199 additions and 28 deletions

View File

@@ -2,6 +2,46 @@
All notable changes to this package will be documented in this file.
## [2.3.9] - 2025-05-13
### Improvements
- 增加了YOO_ASSET_EXPERIMENT宏用于控制实验性代码的开关。
- 构建管线目前会输出构建日志到输出目录下,方便查看引擎在构建时主动清空的控制台日志。
- 优化了收集器tag传染扩散逻辑避免Group里配置了Tag导致的无意义的警告信息。
- 扩展工程内PanelMonitor代码默认关闭状态。
### Fixed
- (#528) 修复了AssetDependencyDatabase在查询引擎资源对象是否存在的时效问题。
### Added
- (#542) 新增了资源管理系统销毁方法。
该方法会销毁所有的资源包裹和异步操作任务以及卸载所有AssetBundle对象
```csharp
public class YooAssets
{
/// <summary>
/// 销毁资源系统
/// </summary>
public static void Destroy();
}
```
- 新增了SBP构建管线的构建参数
```csharp
/// <summary>
/// 从AssetBundle文件头里剥离Unity版本信息
/// </summary>
public bool StripUnityVersion = false;
```
- 新增了构建错误码BuiltinShadersBundleNameIsNull
## [2.3.8] - 2025-04-17
### Improvements

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
#if YOO_ASSET_EXPERIMENT
namespace YooAsset.Editor
{
public class MacroDefine
@@ -15,3 +16,4 @@ namespace YooAsset.Editor
};
}
}
#endif

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Xml;
using UnityEditor;
#if YOO_ASSET_EXPERIMENT
namespace YooAsset.Editor
{
[InitializeOnLoad]
@@ -22,13 +23,21 @@ namespace YooAsset.Editor
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();
using (var memoryStream = new MemoryStream())
{
var writerSettings = new XmlWriterSettings
{
Indent = true,
Encoding = new UTF8Encoding(false), //无BOM
OmitXmlDeclaration = false
};
using (var xmlWriter = XmlWriter.Create(memoryStream, writerSettings))
{
xmlDoc.Save(xmlWriter);
}
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
}
/// <summary>
@@ -94,3 +103,4 @@ namespace YooAsset.Editor
}
}
}
#endif

View File

@@ -32,8 +32,9 @@ namespace YooAsset.Editor
var buildParametersContext = new BuildParametersContext(buildParameters);
_buildContext.SetContextObject(buildParametersContext);
// 初始化日志
BuildLogger.InitLogger(enableLog);
// 初始化日志系统
string logFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/buildInfo.log";
BuildLogger.InitLogger(enableLog, logFilePath);
// 执行构建流程
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
@@ -50,6 +51,9 @@ namespace YooAsset.Editor
BuildLogger.Error(buildResult.ErrorInfo);
}
// 关闭日志系统
BuildLogger.Shuntdown();
return buildResult;
}
}

View File

@@ -11,7 +11,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var buildParameters = buildParametersContext.Parameters;
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
// 检测基础构建参数
buildParametersContext.CheckBuildParameters();
@@ -50,6 +50,13 @@ namespace YooAsset.Editor
{
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
}
// 检测内置着色器资源包名称
if (string.IsNullOrEmpty(buildParameters.BuiltinShadersBundleName))
{
string warning = BuildLogger.GetErrorMessage(ErrorCode.BuiltinShadersBundleNameIsNull, $"Builtin shaders bundle name is null. It will cause resource redundancy !");
BuildLogger.Warning(warning);
}
}
}
}

View File

@@ -14,6 +14,11 @@ namespace YooAsset.Editor
/// </summary>
public ECompressOption CompressOption = ECompressOption.Uncompressed;
/// <summary>
/// 从AssetBundle文件头里剥离Unity版本信息
/// </summary>
public bool StripUnityVersion = false;
/// <summary>
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
/// </summary>
@@ -70,6 +75,9 @@ namespace YooAsset.Editor
else
throw new System.NotImplementedException(CompressOption.ToString());
if (StripUnityVersion)
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.StripUnityVersion;
if (DisableWriteTypeTree)
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;

View File

@@ -2,37 +2,100 @@
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
namespace YooAsset.Editor
{
internal static class BuildLogger
{
private static bool _enableLog = true;
private const int MAX_LOG_BUFFER_SIZE = 1024 * 1024 * 2; //2MB
public static void InitLogger(bool enableLog)
private static bool _enableLog = true;
private static string _logFilePath;
private static readonly object _lockObj = new object();
private static readonly StringBuilder _logBuilder = new StringBuilder(MAX_LOG_BUFFER_SIZE);
/// <summary>
/// 初始化日志系统
/// </summary>
public static void InitLogger(bool enableLog, string logFilePath)
{
_enableLog = enableLog;
_logFilePath = logFilePath;
_logBuilder.Clear();
if (_enableLog)
{
if (string.IsNullOrEmpty(_logFilePath))
throw new Exception("Log file path is null or empty !");
Debug.Log($"Logger initialized at {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
}
}
/// <summary>
/// 关闭日志系统
/// </summary>
public static void Shuntdown()
{
if (_enableLog)
{
lock (_lockObj)
{
try
{
if (File.Exists(_logFilePath))
File.Delete(_logFilePath);
FileUtility.CreateFileDirectory(_logFilePath);
File.WriteAllText(_logFilePath, _logBuilder.ToString(), Encoding.UTF8);
_logBuilder.Clear();
}
catch (Exception ex)
{
Debug.LogError($"Failed to write log file: {ex.Message}");
}
}
}
}
public static void Log(string message)
{
if (_enableLog)
{
WriteLog("INFO", message);
Debug.Log(message);
}
}
public static void Warning(string message)
{
Debug.LogWarning(message);
if (_enableLog)
{
WriteLog("WARN", message);
Debug.LogWarning(message);
}
}
public static void Error(string message)
{
Debug.LogError(message);
if (_enableLog)
{
WriteLog("ERROR", message);
Debug.LogError(message);
}
}
public static string GetErrorMessage(ErrorCode code, string message)
{
return $"[ErrorCode{(int)code}] {message}";
}
private static void WriteLog(string level, string message)
{
lock (_lockObj)
{
string logEntry = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} [{level}] {message}";
_logBuilder.AppendLine(logEntry);
}
}
}
}

View File

@@ -15,6 +15,7 @@ namespace YooAsset.Editor
BuildPipelineIsNullOrEmpty = 116,
BuildBundleTypeIsUnknown = 117,
RecommendScriptBuildPipeline = 130,
BuiltinShadersBundleNameIsNull = 131,
// TaskGetBuildMap
RemoveInvalidTags = 200,

View File

@@ -259,10 +259,13 @@ namespace YooAsset.Editor
}
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
{
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
tags.AddRange(temper);
return tags;
List<string> result = EditorTools.StringToStringList(AssetTags, ';');
if (CollectorType == ECollectorType.MainAssetCollector)
{
List<string> temps = EditorTools.StringToStringList(group.AssetTags, ';');
result.AddRange(temps);
}
return result;
}
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{

View File

@@ -70,7 +70,7 @@ namespace YooAsset.Editor
foreach (var cacheInfoPair in _database)
{
var assetPath = cacheInfoPair.Key;
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath, AssetPathToGUIDOptions.OnlyExistingAssets);
if (string.IsNullOrEmpty(assetGUID))
{
removeList.Add(assetPath);

View File

@@ -296,6 +296,7 @@ namespace YooAsset.Editor
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
string fileContent = JsonUtility.ToJson(_currentReport, true);
FileUtility.WriteAllText(filePath, fileContent);
Debug.Log($"Debug report file saved : {filePath}");
}
}
private void OnSearchKeyWordChange(ChangeEvent<string> e)

View File

@@ -122,7 +122,7 @@ namespace YooAsset
{
if (_disableUnityWebCache)
{
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, 0);
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, Bundle.UnityCRC);
#if UNITY_2020_3_OR_NEWER
downloadhandler.autoLoadAssetBundle = false;
#endif
@@ -132,9 +132,8 @@ namespace YooAsset
{
// 注意:优先从浏览器缓存里获取文件
// The file hash defining the version of the asset bundle.
uint unityCRC = Bundle.UnityCRC;
Hash128 fileHash = Hash128.Parse(Bundle.FileHash);
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, fileHash, unityCRC);
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, fileHash, Bundle.UnityCRC);
#if UNITY_2020_3_OR_NEWER
downloadhandler.autoLoadAssetBundle = false;
#endif

View File

@@ -63,6 +63,22 @@ namespace YooAsset
}
}
/// <summary>
/// 销毁资源系统
/// </summary>
public static void Destroy()
{
if (_isInitialize)
{
_isInitialize = false;
if (_driver != null)
GameObject.Destroy(_driver);
OnApplicationQuit(true);
}
}
/// <summary>
/// 更新资源系统
/// </summary>
@@ -77,7 +93,7 @@ namespace YooAsset
/// <summary>
/// 应用程序退出处理
/// </summary>
internal static void OnApplicationQuit()
internal static void OnApplicationQuit(bool unloadAllAssetBundles)
{
// 说明在编辑器下确保播放被停止时IO类操作被终止。
foreach (var package in _packages)
@@ -85,6 +101,15 @@ namespace YooAsset
OperationSystem.ClearPackageOperation(package.PackageName);
}
OperationSystem.DestroyAll();
// 清空资源包裹列表
_packages.Clear();
// 卸载所有AssetBundle
if (unloadAllAssetBundles)
{
AssetBundle.UnloadAllAssetBundles(true);
}
}
/// <summary>

View File

@@ -24,7 +24,7 @@ namespace YooAsset
#if UNITY_EDITOR
void OnApplicationQuit()
{
YooAssets.OnApplicationQuit();
YooAssets.OnApplicationQuit(false);
}
#endif

View File

@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR && UNITY_2021_3_OR_NEWER
using System.IO;
using UnityEngine;
using UnityEngine.UI;
@@ -6,6 +6,11 @@ using UnityEngine.U2D;
public static class UIPanelSettings
{
/// <summary>
/// 是否开启面板监测
/// </summary>
public static bool EnablePanelMonitor = false;
/// <summary>
/// 面板文件夹GUID
/// </summary>
@@ -60,6 +65,9 @@ public class UIPanelMonitor : UnityEditor.Editor
static void OnPrefabSaving(GameObject go)
{
if (UIPanelSettings.EnablePanelMonitor == false)
return;
UnityEditor.SceneManagement.PrefabStage stage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
if (stage != null)
{
@@ -78,7 +86,7 @@ public class UIPanelMonitor : UnityEditor.Editor
/// <summary>
/// 刷新面板清单
/// </summary>
public static void RefreshPanelManifest(PanelManifest manifest)
private static void RefreshPanelManifest(PanelManifest manifest)
{
manifest.ReferencesAtlas.Clear();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 300 KiB

View File

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