mirror of https://github.com/tuyoogame/YooAsset
update asset bundle collector
parent
6877900ac2
commit
e02fe2331d
|
@ -40,11 +40,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public System.Type AssetType { private set; get; }
|
public System.Type AssetType { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否为着色器资源
|
|
||||||
/// </summary>
|
|
||||||
public bool IsShaderAsset { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -66,10 +61,6 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
|
||||||
IsShaderAsset = true;
|
|
||||||
else
|
|
||||||
IsShaderAsset = false;
|
|
||||||
}
|
}
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(string assetPath)
|
||||||
{
|
{
|
||||||
|
@ -79,10 +70,6 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
|
||||||
IsShaderAsset = true;
|
|
||||||
else
|
|
||||||
IsShaderAsset = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -279,20 +279,21 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
if (command.AutoCollectShaders)
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
PackRuleResult packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
return packRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
{
|
||||||
}
|
// 获取着色器打包规则结果
|
||||||
else
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
{
|
return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
// 获取其它资源打包规则结果
|
}
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
|
||||||
PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
|
||||||
return packRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取其它资源打包规则结果
|
||||||
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
|
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
|
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreDefaultType = true;
|
public bool IgnoreDefaultType = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoCollectShaders = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -101,7 +101,12 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 创建资源收集命令
|
// 创建资源收集命令
|
||||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||||
package.EnableAddressable, package.LocationToLower, package.IncludeAssetGUID, package.IgnoreDefaultType, UniqueBundleName);
|
package.EnableAddressable,
|
||||||
|
package.LocationToLower,
|
||||||
|
package.IncludeAssetGUID,
|
||||||
|
package.IgnoreDefaultType,
|
||||||
|
package.AutoCollectShaders,
|
||||||
|
UniqueBundleName);
|
||||||
|
|
||||||
// 获取收集的资源集合
|
// 获取收集的资源集合
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
|
|
|
@ -27,18 +27,20 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private VisualElement _helpBoxContainer;
|
private VisualElement _helpBoxContainer;
|
||||||
|
|
||||||
private VisualElement _setting1Container;
|
|
||||||
private Button _globalSettingsButton;
|
private Button _globalSettingsButton;
|
||||||
|
private Button _packageSettingsButton;
|
||||||
|
|
||||||
|
private VisualElement _setting1Container;
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _showEditorAliasToggle;
|
private Toggle _showEditorAliasToggle;
|
||||||
private Toggle _uniqueBundleNameToogle;
|
private Toggle _uniqueBundleNameToogle;
|
||||||
|
|
||||||
private VisualElement _setting3Container;
|
private VisualElement _setting2Container;
|
||||||
private Button _packageSettingsButton;
|
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _locationToLowerToogle;
|
private Toggle _locationToLowerToogle;
|
||||||
private Toggle _includeAssetGUIDToogle;
|
private Toggle _includeAssetGUIDToogle;
|
||||||
private Toggle _ignoreDefaultTypeToogle;
|
private Toggle _ignoreDefaultTypeToogle;
|
||||||
|
private Toggle _autoCollectShadersToogle;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
|
@ -91,10 +93,13 @@ namespace YooAsset.Editor
|
||||||
// 警示栏
|
// 警示栏
|
||||||
_helpBoxContainer = root.Q("HelpBoxContainer");
|
_helpBoxContainer = root.Q("HelpBoxContainer");
|
||||||
|
|
||||||
// 公共设置相关
|
|
||||||
_setting1Container = root.Q("PublicContainer1");
|
|
||||||
_globalSettingsButton = root.Q<Button>("GlobalSettingsButton");
|
_globalSettingsButton = root.Q<Button>("GlobalSettingsButton");
|
||||||
_globalSettingsButton.clicked += GlobalSettingsBtn_clicked;
|
_globalSettingsButton.clicked += GlobalSettingsBtn_clicked;
|
||||||
|
_packageSettingsButton = root.Q<Button>("PackageSettingsButton");
|
||||||
|
_packageSettingsButton.clicked += PackageSettingsBtn_clicked;
|
||||||
|
|
||||||
|
// 公共设置相关
|
||||||
|
_setting1Container = root.Q("PublicContainer1");
|
||||||
_showPackageToogle = root.Q<Toggle>("ShowPackages");
|
_showPackageToogle = root.Q<Toggle>("ShowPackages");
|
||||||
_showPackageToogle.RegisterValueChangedCallback(evt =>
|
_showPackageToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -115,9 +120,7 @@ namespace YooAsset.Editor
|
||||||
});
|
});
|
||||||
|
|
||||||
// 包裹设置相关
|
// 包裹设置相关
|
||||||
_setting3Container = root.Q("PublicContainer3");
|
_setting2Container = root.Q("PublicContainer2");
|
||||||
_packageSettingsButton = root.Q<Button>("PackageSettingsButton");
|
|
||||||
_packageSettingsButton.clicked += PackageSettingsBtn_clicked;
|
|
||||||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -162,6 +165,17 @@ namespace YooAsset.Editor
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_autoCollectShadersToogle = root.Q<Toggle>("AutoCollectShaders");
|
||||||
|
_autoCollectShadersToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
|
if (selectPackage != null)
|
||||||
|
{
|
||||||
|
selectPackage.AutoCollectShaders = evt.newValue;
|
||||||
|
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
|
@ -458,17 +472,22 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_showPackageSettings = false;
|
||||||
_packageSettingsButton.SetEnabled(false);
|
_packageSettingsButton.SetEnabled(false);
|
||||||
if(_packageListView.itemsSource.Count == 0)
|
if (_packageListView.itemsSource.Count == 0)
|
||||||
_packageSettingsButton.text = $"Not Found Any Package !";
|
_packageSettingsButton.text = $"Not Found Any Package !";
|
||||||
else
|
else
|
||||||
_packageSettingsButton.text = $"Package Setting";
|
_packageSettingsButton.text = $"Package Setting";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_showPackageSettings)
|
if (_showPackageSettings)
|
||||||
_setting3Container.style.display = DisplayStyle.Flex;
|
{
|
||||||
|
_setting2Container.style.display = DisplayStyle.Flex;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_setting3Container.style.display = DisplayStyle.None;
|
{
|
||||||
|
_setting2Container.style.display = DisplayStyle.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void RefreshHelpBoxTips()
|
private void RefreshHelpBoxTips()
|
||||||
{
|
{
|
||||||
|
@ -539,7 +558,6 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
_groupContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
_collectorContainer.visible = false;
|
_collectorContainer.visible = false;
|
||||||
_showPackageSettings = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -952,8 +970,14 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild, _packageNameTxt.value,
|
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
||||||
_enableAddressableToogle.value, _locationToLowerToogle.value, _includeAssetGUIDToogle.value, _ignoreDefaultTypeToogle.value, _uniqueBundleNameToogle.value);
|
_packageNameTxt.value,
|
||||||
|
_enableAddressableToogle.value,
|
||||||
|
_locationToLowerToogle.value,
|
||||||
|
_includeAssetGUIDToogle.value,
|
||||||
|
_ignoreDefaultTypeToogle.value,
|
||||||
|
_autoCollectShadersToogle.value,
|
||||||
|
_uniqueBundleNameToogle.value);
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
|
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
|
||||||
<ui:VisualElement name="GlobalSettingsContainer">
|
<ui:VisualElement name="GlobalSettingsContainer">
|
||||||
<ui:Button text="Global Settings" display-tooltip-when-elided="true" name="GlobalSettingsButton" />
|
<ui:Button text="Global Settings" name="GlobalSettingsButton" />
|
||||||
<ui:VisualElement name="PublicContainer1" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
<ui:VisualElement name="PublicContainer1" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||||
<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="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
@ -17,11 +17,12 @@
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="PackageSettingsContainer">
|
<ui:VisualElement name="PackageSettingsContainer">
|
||||||
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
||||||
<ui:VisualElement name="PublicContainer3" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
<ui:VisualElement name="PublicContainer2" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||||
<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="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Ignore Default Type" name="IgnoreDefaultType" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Ignore Default Type" name="IgnoreDefaultType" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID { private set; get; }
|
public bool IncludeAssetGUID { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动收集所有着色器
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoCollectShaders { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -44,7 +49,7 @@ namespace YooAsset.Editor
|
||||||
public string ShadersBundleName { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool uniqueBundleName)
|
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
@ -52,6 +57,7 @@ namespace YooAsset.Editor
|
||||||
LocationToLower = locationToLower;
|
LocationToLower = locationToLower;
|
||||||
IncludeAssetGUID = includeAssetGUID;
|
IncludeAssetGUID = includeAssetGUID;
|
||||||
IgnoreDefaultType = ignoreDefaultType;
|
IgnoreDefaultType = ignoreDefaultType;
|
||||||
|
AutoCollectShaders = autoCollectShaders;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
|
||||||
// 着色器统一全名称
|
// 着色器统一全名称
|
||||||
|
|
Loading…
Reference in New Issue