46 lines
2.0 KiB
C#
46 lines
2.0 KiB
C#
#if UNITY_EDITOR
|
|
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using YooAsset.Editor;
|
|
|
|
namespace AIGame.EditorTools
|
|
{
|
|
/// <summary>把 Candy UI Prefab 收进 Art;图片/字体通过 Prefab 依赖进入资源包。</summary>
|
|
public static class SetupUiBundleCollector
|
|
{
|
|
[MenuItem("Tools/UI/Setup UI Bundle Collector")]
|
|
public static string Setup()
|
|
{
|
|
var package = BundleCollectorSettingData.Setting.Packages.FirstOrDefault(p => p.PackageName == "Art");
|
|
if (package == null) throw new System.InvalidOperationException("Set up the Art package before UI collection.");
|
|
var group = package.Groups.FirstOrDefault(g => g.GroupName == "UI");
|
|
if (group == null) group = BundleCollectorSettingData.CreateGroup(package, "UI");
|
|
group.GroupDesc = "Candy UI";
|
|
group.AssetTags = "ui";
|
|
group.ActiveRuleName = nameof(EnableGroup);
|
|
BundleCollectorSettingData.ModifyGroup(package, group);
|
|
const string path = "Assets/Bundles/UI/Prefab";
|
|
var collector = group.Collectors.FirstOrDefault(c => c.CollectPath == path);
|
|
if (collector == null)
|
|
{
|
|
collector = new BundleCollector
|
|
{
|
|
CollectPath = path,
|
|
CollectorGUID = AssetDatabase.AssetPathToGUID(path),
|
|
CollectorType = ECollectorType.MainAssetCollector,
|
|
AddressRuleName = nameof(AddressByFileName),
|
|
PackRuleName = nameof(PackSeparately),
|
|
FilterRuleName = nameof(CollectPrefab),
|
|
AssetTags = "ui"
|
|
};
|
|
BundleCollectorSettingData.CreateCollector(group, collector);
|
|
}
|
|
package.CheckConfigError();
|
|
BundleCollectorSettingData.SaveFile();
|
|
return "Art/UI collects Candy UI by prefab name, including sprite/font dependencies.";
|
|
}
|
|
}
|
|
}
|
|
#endif
|