Update AssetBundleCollector
parent
5199430766
commit
8389ce5793
|
@ -132,10 +132,10 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
// 注意:模拟构建模式下只收集主资源
|
// 注意:模拟构建模式下只收集主资源
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
|
@ -162,7 +162,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -177,7 +177,7 @@ namespace YooAsset.Editor
|
||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
@ -207,7 +207,7 @@ namespace YooAsset.Editor
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
string address = GetAddress(group, assetPath);
|
string address = GetAddress(group, assetPath);
|
||||||
string bundleName = GetBundleName(group, assetPath);
|
string bundleName = GetBundleName(group, assetPath);
|
||||||
|
@ -215,7 +215,7 @@ namespace YooAsset.Editor
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<string>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ namespace YooAsset.Editor
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
|
var temper = collector.GetAllCollectAssets(command, this);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
|
@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|
|
@ -56,14 +56,14 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
|
var temper = group.GetAllCollectAssets(command);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
|
@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示包裹视图
|
/// 是否显示包裹列表视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowPackageView = false;
|
public bool ShowPackageView = false;
|
||||||
|
|
||||||
|
@ -18,6 +18,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -76,37 +81,43 @@ namespace YooAsset.Editor
|
||||||
Debug.LogWarning($"Not found package : {packageName}");
|
Debug.LogWarning($"Not found package : {packageName}");
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹收集的资源文件
|
/// 获取包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
|
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(packageName))
|
if (string.IsNullOrEmpty(packageName))
|
||||||
throw new Exception("Build Package name is null or mepty !");
|
throw new Exception("Build package name is null or mepty !");
|
||||||
|
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
{
|
{
|
||||||
return package.GetAllCollectAssets(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||||
|
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
|
return collectResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception($"Not found collector pacakge : {packageName}");
|
throw new Exception($"Not found collector pacakge : {packageName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有包裹收集的资源文件
|
/// 获取所有包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllPackageAssets(EBuildMode buildMode)
|
public List<CollectResult> GetAllPackageAssets(EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
List<CollectAssetInfo> result = new List<CollectAssetInfo>(1000);
|
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||||
result.AddRange(temper);
|
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
|
collectResultList.Add(collectResult);
|
||||||
}
|
}
|
||||||
return result;
|
return collectResultList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -347,6 +347,11 @@ namespace YooAsset.Editor
|
||||||
Setting.EnableAddressable = enableAddressable;
|
Setting.EnableAddressable = enableAddressable;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
Setting.UniqueBundleName = uniqueBundleName;
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 资源包裹编辑相关
|
// 资源包裹编辑相关
|
||||||
public static void CreatePackage(string packageName)
|
public static void CreatePackage(string packageName)
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
private Toggle _uniqueBundleNameToogle;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
|
@ -87,6 +88,12 @@ namespace YooAsset.Editor
|
||||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
||||||
|
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
|
@ -733,8 +740,8 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<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: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;">
|
||||||
|
|
|
@ -50,5 +50,13 @@ namespace YooAsset.Editor
|
||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名称追加包裹名
|
||||||
|
/// </summary>
|
||||||
|
public void BundleNameAppendPackageName(string packageName)
|
||||||
|
{
|
||||||
|
BundleName = $"{packageName.ToLower()}_{BundleName}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class CollectCommand
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构建模式
|
||||||
|
/// </summary>
|
||||||
|
public EBuildMode BuildMode { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
|
public CollectCommand(EBuildMode buildMode, bool enableAddressable)
|
||||||
|
{
|
||||||
|
BuildMode = buildMode;
|
||||||
|
EnableAddressable = enableAddressable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b1741e85d76b28d41a4da3cd0e3e6f20
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class CollectResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集的资源信息列表
|
||||||
|
/// </summary>
|
||||||
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
EnableAddressable = enableAddressable;
|
||||||
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||||
|
{
|
||||||
|
CollectAssets = collectAssets;
|
||||||
|
|
||||||
|
if (UniqueBundleName)
|
||||||
|
{
|
||||||
|
foreach (var collectAsset in CollectAssets)
|
||||||
|
{
|
||||||
|
collectAsset.BundleNameAppendPackageName(PackageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dbbd465f929ee33408441b62d19c7d10
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue