TEngine 6

This commit is contained in:
Alex-Rachel
2025-03-07 23:09:46 +08:00
parent aad8ff3ee5
commit 551727687f
1988 changed files with 46223 additions and 94880 deletions

View File

@@ -140,7 +140,7 @@ namespace YooAsset.Editor
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
{
// 注意:模拟构建模式下只收集主资源
if (command.BuildMode == EBuildMode.SimulateBuild)
if (command.SimulateBuild)
{
if (CollectorType != ECollectorType.MainAssetCollector)
return new List<CollectAssetInfo>();
@@ -149,7 +149,7 @@ namespace YooAsset.Editor
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
// 收集打包资源路径
List<string> findAssets =new List<string>();
List<string> findAssets = new List<string>();
if (AssetDatabase.IsValidFolder(CollectPath))
{
string collectDirectory = CollectPath;
@@ -218,13 +218,7 @@ namespace YooAsset.Editor
string bundleName = GetBundleName(command, group, assetInfo);
List<string> assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetInfo, assetTags);
// 注意:模拟构建模式下不需要收集依赖资源
if (command.BuildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List<AssetInfo>();
else
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
return collectAssetInfo;
}
@@ -272,7 +266,11 @@ namespace YooAsset.Editor
}
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
// 注意:模拟构建模式下不需要收集依赖资源
if (command.SimulateBuild)
return new List<AssetInfo>();
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);
List<AssetInfo> result = new List<AssetInfo>(depends.Length);
foreach (string assetPath in depends)
{

View File

@@ -46,7 +46,7 @@ namespace YooAsset.Editor
// 检测分组是否激活
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
if (activeRule.IsActiveGroup() == false)
if (activeRule.IsActiveGroup(new GroupData(GroupName)) == false)
return;
foreach (var collector in Collectors)
@@ -80,7 +80,7 @@ namespace YooAsset.Editor
// 检测分组是否激活
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
if (activeRule.IsActiveGroup() == false)
if (activeRule.IsActiveGroup(new GroupData(GroupName)) == false)
{
return new List<CollectAssetInfo>();
}

View File

@@ -98,9 +98,9 @@ namespace YooAsset.Editor
}
/// <summary>
/// 获取打包收集的资源文件
/// 获取收集的资源列表
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
public List<CollectAssetInfo> GetCollectAssets(CollectCommand command)
{
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
@@ -138,7 +138,7 @@ namespace YooAsset.Editor
}
}
// 返回列表
// 返回结果
return result.Values.ToList();
}

View File

@@ -86,10 +86,16 @@ namespace YooAsset.Editor
return package.GetAllTags();
}
[Obsolete("This method will be removed in a future ! Use BeginCollect instead.", true)]
public CollectResult GetPackageAssets(bool simulateBuild, bool useAssetDependencyDB, string packageName)
{
return BeginCollect(packageName, simulateBuild, useAssetDependencyDB);
}
/// <summary>
/// 获取包裹收集的资源文件
/// 收集指定包裹的资源文件
/// </summary>
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
public CollectResult BeginCollect(string packageName, bool simulateBuild, bool useAssetDependencyDB)
{
if (string.IsNullOrEmpty(packageName))
throw new Exception("Build package name is null or empty !");
@@ -100,16 +106,18 @@ namespace YooAsset.Editor
// 创建资源收集命令
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
CollectCommand command = new CollectCommand(buildMode, packageName,
package.EnableAddressable,
package.LocationToLower,
package.IncludeAssetGUID,
package.AutoCollectShaders,
UniqueBundleName, ignoreRule);
var command = new CollectCommand(packageName, ignoreRule);
command.SimulateBuild = simulateBuild;
command.UniqueBundleName = UniqueBundleName;
command.UseAssetDependencyDB = useAssetDependencyDB;
command.EnableAddressable = package.EnableAddressable;
command.LocationToLower = package.LocationToLower;
command.IncludeAssetGUID = package.IncludeAssetGUID;
command.AutoCollectShaders = package.AutoCollectShaders;
// 获取收集的资源集合
CollectResult collectResult = new CollectResult(command);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
// 开始收集工作
var collectAssets = package.GetCollectAssets(command);
var collectResult = new CollectResult(command, collectAssets);
return collectResult;
}

View File

@@ -23,7 +23,7 @@ namespace YooAsset.Editor
private static readonly Dictionary<string, System.Type> _cacheIgnoreRuleTypes = new Dictionary<string, System.Type>();
private static readonly Dictionary<string, IIgnoreRule> _cacheIgnoreRuleInstance = new Dictionary<string, IIgnoreRule>();
/// <summary>
/// 配置数据是否被修改
/// </summary>
@@ -201,7 +201,6 @@ namespace YooAsset.Editor
public static void ClearAll()
{
Setting.ClearAll();
SaveFile();
}
public static List<RuleDisplayName> GetActiveRuleNames()
@@ -275,23 +274,23 @@ namespace YooAsset.Editor
public static bool HasActiveRuleName(string ruleName)
{
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
return _cacheActiveRuleTypes.ContainsKey(ruleName);
}
public static bool HasAddressRuleName(string ruleName)
{
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
return _cacheAddressRuleTypes.ContainsKey(ruleName);
}
public static bool HasPackRuleName(string ruleName)
{
return _cachePackRuleTypes.Keys.Contains(ruleName);
return _cachePackRuleTypes.ContainsKey(ruleName);
}
public static bool HasFilterRuleName(string ruleName)
{
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
return _cacheFilterRuleTypes.ContainsKey(ruleName);
}
public static bool HasIgnoreRuleName(string ruleName)
{
return _cacheIgnoreRuleTypes.Keys.Contains(ruleName);
return _cacheIgnoreRuleTypes.ContainsKey(ruleName);
}
public static IActiveRule GetActiveRuleInstance(string ruleName)

View File

@@ -42,7 +42,7 @@ namespace YooAsset.Editor
private Toggle _includeAssetGUIDToogle;
private Toggle _autoCollectShadersToogle;
private PopupField<RuleDisplayName> _ignoreRulePopupField;
private VisualElement _packageContainer;
private ListView _packageListView;
private TextField _packageNameTxt;
@@ -164,25 +164,25 @@ namespace YooAsset.Editor
RefreshWindow();
}
});
// 忽略规则
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
_ignoreRulePopupField.label = "File Ignore Rule";
_ignoreRulePopupField.name = "IgnoreRulePopupField";
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
_ignoreRulePopupField.style.width = 300;
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
{
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
_ignoreRulePopupField.label = "File Ignore Rule";
_ignoreRulePopupField.name = "IgnoreRulePopupField";
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
_ignoreRulePopupField.style.width = 300;
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage != null)
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if(selectPackage != null)
{
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
}
});
_setting2Container.Add(_ignoreRulePopupField);
}
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
}
});
_setting2Container.Add(_ignoreRulePopupField);
// 配置修复按钮
var fixBtn = root.Q<Button>("FixButton");
@@ -205,7 +205,9 @@ namespace YooAsset.Editor
_packageListView = root.Q<ListView>("PackageListView");
_packageListView.makeItem = MakePackageListViewItem;
_packageListView.bindItem = BindPackageListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_packageListView.selectionChanged += PackageListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
#else
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
@@ -250,7 +252,9 @@ namespace YooAsset.Editor
_groupListView = root.Q<ListView>("GroupListView");
_groupListView.makeItem = MakeGroupListViewItem;
_groupListView.bindItem = BindGroupListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_groupListView.selectionChanged += GroupListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
#else
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
@@ -657,7 +661,7 @@ namespace YooAsset.Editor
// 激活状态
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
bool isActive = activeRule.IsActiveGroup();
bool isActive = activeRule.IsActiveGroup(new GroupData(group.GroupName));
textField1.SetEnabled(isActive);
}
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
@@ -991,14 +995,16 @@ namespace YooAsset.Editor
try
{
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
_packageNameTxt.value,
_enableAddressableToogle.value,
_locationToLowerToogle.value,
_includeAssetGUIDToogle.value,
_autoCollectShadersToogle.value,
_uniqueBundleNameToogle.value,
ignoreRule);
string packageName = _packageNameTxt.value;
var command = new CollectCommand(packageName, ignoreRule);
command.SimulateBuild = true;
command.UniqueBundleName = _uniqueBundleNameToogle.value;
command.UseAssetDependencyDB = true;
command.EnableAddressable = _enableAddressableToogle.value;
command.LocationToLower = _locationToLowerToogle.value;
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
command.AutoCollectShaders = _autoCollectShadersToogle.value;
collector.CheckConfigError();
collectAssetInfos = collector.GetAllCollectAssets(command, group);
}

View File

@@ -28,7 +28,7 @@
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
@@ -36,9 +36,9 @@
</ui:VisualElement>
<ui:VisualElement name="GroupContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Label text="Groups" display-tooltip-when-elided="true" name="GroupTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:TextField picking-mode="Ignore" label="Package Name" value="filler text" name="PackageName" style="flex-direction: column;" />
<ui:TextField picking-mode="Ignore" label="Package Desc" value="filler text" name="PackageDesc" style="flex-direction: column;" />
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace YooAsset.Editor
{
public class AssetDependencyCache
{
private readonly AssetDependencyDatabase _database;
/// <summary>
/// 初始化资源依赖缓存系统
/// </summary>
public AssetDependencyCache(bool useAssetDependencyDB)
{
if (useAssetDependencyDB)
Debug.Log("Use asset dependency database !");
string databaseFilePath = "Library/AssetDependencyDB";
_database = new AssetDependencyDatabase();
_database.CreateDatabase(useAssetDependencyDB, databaseFilePath);
if (useAssetDependencyDB)
{
_database.SaveDatabase();
}
}
/// <summary>
/// 获取资源的依赖列表
/// </summary>
/// <param name="assetPath">资源路径</param>
/// <param name="recursive">递归查找所有依赖</param>
/// <returns>返回依赖的资源路径集合</returns>
public string[] GetDependencies(string assetPath, bool recursive = true)
{
// 通过本地缓存获取依赖关系
return _database.GetDependencies(assetPath, recursive);
// 通过Unity引擎获取依赖关系
//return AssetDatabase.GetDependencies(assetPath, recursive);
}
}
}

View File

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

View File

@@ -0,0 +1,258 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace YooAsset.Editor
{
/// <summary>
/// 资源依赖数据库
/// </summary>
public class AssetDependencyDatabase
{
private const string FILE_VERSION = "1.0";
private class DependencyInfo
{
/// <summary>
/// 此哈希函数会聚合了以下内容:源资源路径、源资源、元文件、目标平台以及导入器版本。
/// 如果此哈希值发送变化,则说明导入资源可能已更改,因此应重新搜集依赖关系。
/// </summary>
public string DependHash;
/// <summary>
/// 直接依赖资源的GUID列表
/// </summary>
public List<string> DependGUIDs = new List<string>();
}
private string _databaseFilePath;
private readonly Dictionary<string, DependencyInfo> _database = new Dictionary<string, DependencyInfo>(100000);
/// <summary>
/// 创建缓存数据库
/// </summary>
public void CreateDatabase(bool readCacheDatabaseFile, string databaseFilePath)
{
_databaseFilePath = databaseFilePath;
_database.Clear();
FileStream stream = null;
BinaryReader reader = null;
try
{
if (readCacheDatabaseFile && File.Exists(databaseFilePath))
{
// 解析缓存文件
stream = File.OpenRead(databaseFilePath);
reader = new BinaryReader(stream);
string fileVersion = reader.ReadString();
if (fileVersion != FILE_VERSION)
throw new Exception("The database file version not match !");
var count = reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var assetPath = reader.ReadString();
var cacheInfo = new DependencyInfo
{
DependHash = reader.ReadString(),
DependGUIDs = ReadStringList(reader),
};
_database.Add(assetPath, cacheInfo);
}
// 移除无效资源
List<string> removeList = new List<string>(10000);
foreach (var cacheInfoPair in _database)
{
var assetPath = cacheInfoPair.Key;
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
if (string.IsNullOrEmpty(assetGUID))
{
removeList.Add(assetPath);
}
}
foreach (var assetPath in removeList)
{
_database.Remove(assetPath);
}
}
}
catch (Exception ex)
{
ClearDatabase(true);
Debug.LogError($"Failed to load cache database : {ex.Message}");
}
finally
{
if (reader != null)
reader.Close();
if (stream != null)
stream.Close();
}
// 查找新增或变动资源
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
foreach (var assetPath in allAssetPaths)
{
if (_database.TryGetValue(assetPath, out DependencyInfo cacheInfo))
{
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
if (dependHash.ToString() != cacheInfo.DependHash)
{
_database[assetPath] = CreateDependencyInfo(assetPath);
}
}
else
{
var newCacheInfo = CreateDependencyInfo(assetPath);
_database.Add(assetPath, newCacheInfo);
}
}
}
/// <summary>
/// 保存缓存数据库
/// </summary>
public void SaveDatabase()
{
if (File.Exists(_databaseFilePath))
File.Delete(_databaseFilePath);
FileStream stream = null;
BinaryWriter writer = null;
try
{
stream = File.Create(_databaseFilePath);
writer = new BinaryWriter(stream);
writer.Write(FILE_VERSION);
writer.Write(_database.Count);
foreach (var assetPair in _database)
{
string assetPath = assetPair.Key;
var assetInfo = assetPair.Value;
writer.Write(assetPath);
writer.Write(assetInfo.DependHash);
WriteStringList(writer, assetInfo.DependGUIDs);
}
writer.Flush();
}
catch (Exception ex)
{
Debug.LogError($"Failed to save cache database : {ex.Message}");
}
finally
{
if (writer != null)
writer.Close();
if (stream != null)
stream.Close();
}
}
/// <summary>
/// 清理缓存数据库
/// </summary>
public void ClearDatabase(bool deleteDatabaseFile)
{
if (deleteDatabaseFile)
{
if (File.Exists(_databaseFilePath))
File.Delete(_databaseFilePath);
}
_database.Clear();
}
/// <summary>
/// 获取资源的依赖列表
/// </summary>
public string[] GetDependencies(string assetPath, bool recursive)
{
// 注意AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
// 注意AssetDatabase.GetDependencies()方法返回结果里会包含主资源路径!
// 注意:机制上不允许存在未收录的资源
if (_database.ContainsKey(assetPath) == false)
{
throw new Exception($"Fatal : can not found cache info : {assetPath}");
}
var result = new HashSet<string> { assetPath };
CollectDependencies(assetPath, result, recursive);
// 注意AssetDatabase.GetDependencies保持一致将主资源添加到依赖列表最前面
return result.ToArray();
}
private void CollectDependencies(string assetPath, HashSet<string> result, bool recursive)
{
if (_database.TryGetValue(assetPath, out var cacheInfo) == false)
{
throw new Exception($"Fatal : can not found cache info : {assetPath}");
}
foreach (var dependGUID in cacheInfo.DependGUIDs)
{
string dependAssetPath = AssetDatabase.GUIDToAssetPath(dependGUID);
if (string.IsNullOrEmpty(dependAssetPath))
continue;
// 如果是文件夹资源
if (AssetDatabase.IsValidFolder(dependAssetPath))
continue;
// 如果已经收集过
if (result.Contains(dependAssetPath))
continue;
result.Add(dependAssetPath);
// 递归收集依赖
if (recursive)
CollectDependencies(dependAssetPath, result, recursive);
}
}
private List<string> ReadStringList(BinaryReader reader)
{
var count = reader.ReadInt32();
var values = new List<string>(count);
for (int i = 0; i < count; i++)
{
values.Add(reader.ReadString());
}
return values;
}
private void WriteStringList(BinaryWriter writer, List<string> values)
{
writer.Write(values.Count);
foreach (var value in values)
{
writer.Write(value);
}
}
private DependencyInfo CreateDependencyInfo(string assetPath)
{
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
var dependGUIDs = new List<string>();
foreach (var dependAssetPath in dependAssetPaths)
{
string guid = AssetDatabase.AssetPathToGUID(dependAssetPath);
if (string.IsNullOrEmpty(guid) == false)
{
dependGUIDs.Add(guid);
}
}
var cacheInfo = new DependencyInfo();
cacheInfo.DependHash = dependHash.ToString();
cacheInfo.DependGUIDs = dependGUIDs;
return cacheInfo;
}
}
}

View File

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

View File

@@ -3,68 +3,67 @@ namespace YooAsset.Editor
{
public class CollectCommand
{
/// <summary>
/// 构建模式
/// </summary>
public EBuildMode BuildMode { private set; get; }
/// <summary>
/// 包裹名称
/// </summary>
public string PackageName { private set; get; }
/// <summary>
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable { private set; get; }
/// <summary>
/// 资源定位地址大小写不敏感
/// </summary>
public bool LocationToLower { private set; get; }
/// <summary>
/// 包含资源GUID数据
/// </summary>
public bool IncludeAssetGUID { private set; get; }
/// <summary>
/// 自动收集所有着色器
/// </summary>
public bool AutoCollectShaders { private set; get; }
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName { private set; get; }
/// <summary>
/// 着色器统一全名称
/// </summary>
public string ShadersBundleName { private set; get; }
/// <summary>
/// 忽略规则实例
/// </summary>
public IIgnoreRule IgnoreRule { private set; get; }
public CollectCommand(EBuildMode buildMode, string packageName,
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
{
BuildMode = buildMode;
PackageName = packageName;
EnableAddressable = enableAddressable;
LocationToLower = locationToLower;
IncludeAssetGUID = includeAssetGUID;
AutoCollectShaders = autoCollectShaders;
UniqueBundleName = uniqueBundleName;
IgnoreRule = ignoreRule;
/// <summary>
/// 模拟构建模式
/// </summary>
public bool SimulateBuild { set; get; }
// 着色器统一全名称
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName { set; get; }
/// <summary>
/// 使用资源依赖数据库
/// </summary>
public bool UseAssetDependencyDB { set; get; }
/// <summary>
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable { set; get; }
/// <summary>
/// 资源定位地址大小写不敏感
/// </summary>
public bool LocationToLower { set; get; }
/// <summary>
/// 包含资源GUID数据
/// </summary>
public bool IncludeAssetGUID { set; get; }
/// <summary>
/// 自动收集所有着色器
/// </summary>
public bool AutoCollectShaders { set; get; }
private AssetDependencyCache _assetDependency;
public AssetDependencyCache AssetDependency
{
get
{
if (_assetDependency == null)
_assetDependency = new AssetDependencyCache(UseAssetDependencyDB);
return _assetDependency;
}
}
public CollectCommand(string packageName, IIgnoreRule ignoreRule)
{
PackageName = packageName;
IgnoreRule = ignoreRule;
}
}
}

View File

@@ -15,12 +15,9 @@ namespace YooAsset.Editor
/// </summary>
public List<CollectAssetInfo> CollectAssets { private set; get; }
public CollectResult(CollectCommand command)
public CollectResult(CollectCommand command, List<CollectAssetInfo> collectAssets)
{
Command = command;
}
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
{
CollectAssets = collectAssets;
}
}

View File

@@ -1,6 +1,16 @@

namespace YooAsset.Editor
{
public struct GroupData
{
public string GroupName;
public GroupData(string groupName)
{
GroupName = groupName;
}
}
/// <summary>
/// 资源分组激活规则接口
/// </summary>
@@ -9,6 +19,6 @@ namespace YooAsset.Editor
/// <summary>
/// 是否激活分组
/// </summary>
bool IsActiveGroup();
bool IsActiveGroup(GroupData data);
}
}

View File

@@ -4,7 +4,7 @@ namespace YooAsset.Editor
[DisplayName("启用分组")]
public class EnableGroup : IActiveRule
{
public bool IsActiveGroup()
public bool IsActiveGroup(GroupData data)
{
return true;
}
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
[DisplayName("禁用分组")]
public class DisableGroup : IActiveRule
{
public bool IsActiveGroup()
public bool IsActiveGroup(GroupData data)
{
return false;
}

View File

@@ -20,7 +20,8 @@ namespace YooAsset.Editor
{
public bool IsCollectAsset(FilterRuleData data)
{
return Path.GetExtension(data.AssetPath) == ".unity";
string extension = Path.GetExtension(data.AssetPath);
return extension == ".unity" || extension == ".scene";
}
}

View File

@@ -147,6 +147,22 @@ namespace YooAsset.Editor
}
}
/// <summary>
/// 打包视频文件
/// </summary>
[DisplayName("打包视频文件")]
public class PackVideoFile : IPackRule
{
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
string bundleName = data.AssetPath;
string fileExtension = Path.GetExtension(data.AssetPath);
fileExtension = fileExtension.Remove(0, 1);
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
return result;
}
}
/// <summary>
/// 打包着色器
/// </summary>