feat: Enhance Addressable tools with improved scanning and filtering features
- Updated AddressReferenceGraphWindow to scan for AddressKeys in the _Game directory and added a warning for missing directories. - Enhanced AddressableBatchTool with new filters for asset types (Prefab, Scene, ScriptableObject, Texture, Audio) and improved UI layout for better usability. - Introduced automatic application of grouping and labeling rules during registration in AddressableBatchTool. - Added functionality to quickly scan the _Game folder and improved address building logic. - Updated AddressableRuleSyncWindow to include handling for custom labels and improved reporting of issues. - Enhanced AddressableRules with a whitelist for known labels and refined grouping and labeling logic based on asset prefixes.
This commit is contained in:
@@ -14,23 +14,57 @@ namespace BaseGames.Editor
|
||||
/// </summary>
|
||||
public static class AddressableRules
|
||||
{
|
||||
// ── 已知标签白名单 ────────────────────────────────────────────────────────
|
||||
// AddressableRuleSyncWindow 用此白名单区分:
|
||||
// • 规则要求但缺失 → 红色,必须补齐
|
||||
// • 规则不要求但存在且不在白名单 → 黄色警告(自定义标签,建议写进规范)
|
||||
// • 规则不要求但存在且在白名单 → 白色,合法的人工附加标签
|
||||
// 每次向 AddressablesLabelSpec 新增 Label 时,须同步在此处添加。
|
||||
public static readonly HashSet<string> KnownLabels = new(StringComparer.Ordinal)
|
||||
{
|
||||
AddressKeys.Labels.Preload,
|
||||
AddressKeys.Labels.Poolable,
|
||||
AddressKeys.Labels.Enemy,
|
||||
AddressKeys.Labels.BGM,
|
||||
AddressKeys.Labels.SFX,
|
||||
AddressKeys.Labels.Charms,
|
||||
AddressKeys.Labels.Config,
|
||||
AddressKeys.Labels.Weapon,
|
||||
};
|
||||
|
||||
// ── 前缀 → 分组名 ──────────────────────────────────────────────────────
|
||||
// 规则:按 AssetFolderSpec §8.1 Group 划分策略。
|
||||
// 顺序:更长/更具体的前缀必须排在更短/更泛化的前缀之前,否则短前缀会先匹配。
|
||||
// 特殊:Room_/Boss_ 地址的分组名在运行时动态计算,见 GetExpectedGroup()。
|
||||
public static readonly (string Prefix, string Group)[] PrefixGroupMap =
|
||||
{
|
||||
// ── 场景 ─────────────────────────────────────────────────────────
|
||||
("Scene_", "Scenes"),
|
||||
// ── 玩家 & 武器 ──────────────────────────────────────────────────
|
||||
("PLY_", "Player"),
|
||||
("WPN_", "Player"), // 武器与玩家 Prefab 同组(AssetFolderSpec §8.1)
|
||||
// ── 敌人 & 投射物 ────────────────────────────────────────────────
|
||||
("ENM_", "Enemies"),
|
||||
("PROJ_", "Projectiles"),
|
||||
("VFX_", "VFX_Common"), // 通用特效组(AssetFolderSpec §8.1)
|
||||
// ── 特效 & UI ────────────────────────────────────────────────────
|
||||
("VFX_", "VFX_Common"), // 通用特效(AssetFolderSpec §8.1)
|
||||
("UI_", "UI"),
|
||||
// ── 收集物 ──────────────────────────────────────────────────────
|
||||
("COL_", "Collectibles"),
|
||||
("CHM_", "Config"), // 护身符 SO 归入 Config 组(AddressablesLabelSpec §3.9)
|
||||
("Config/", "Config"),
|
||||
("AUD_", "Audio_Music"),
|
||||
// ── 配置数据(更具体的前缀排在泛化前缀之前)──────────────────────
|
||||
("CHM_", "Config"), // 护身符 SO(AddressablesLabelSpec §3.9)
|
||||
("SKL_", "Config"), // 技能配置 SO(AssetFolderSpec §4)
|
||||
("SPL_", "Config"), // 法术配置 SO
|
||||
("ABL_", "Config"), // 能力配置 SO
|
||||
("MAP_", "Config"), // 地图数据 SO(AssetFolderSpec §4)
|
||||
("Config/", "Config"), // 路径前缀配置(AssetFolderSpec §8.2)
|
||||
// ── 音频(AUD_BGM_ / AUD_SFX_ 必须在通配 AUD_ 之前)─────────────
|
||||
("AUD_BGM_", "Audio_Music"), // BGM 流式音频
|
||||
("AUD_SFX_", "Audio_SFX"), // SFX 音效(独立分组便于包体按需加载)
|
||||
("AUD_", "Audio_Music"), // 未细分音频归 BGM 组
|
||||
// ── 世界 & 持久化 ────────────────────────────────────────────────
|
||||
("WLD_", "World"), // 可交互世界物件 Prefab
|
||||
("SYS_", "Persistent"), // Persistent 场景管理器 Prefab
|
||||
};
|
||||
|
||||
// ── 精确地址 → 标签(优先级高于前缀规则)────────────────────────────────
|
||||
@@ -51,19 +85,33 @@ namespace BaseGames.Editor
|
||||
// 顺序:更具体的前缀(AUD_BGM_)在更泛化的前缀(AUD_)之前。
|
||||
private static readonly (string Prefix, string[] Labels)[] PrefixLabelMap =
|
||||
{
|
||||
// ── 音频(更具体的 AUD_BGM_ / AUD_SFX_ 必须排在 AUD_ 之前)──────
|
||||
("AUD_BGM_", new[] { AddressKeys.Labels.BGM }),
|
||||
("AUD_SFX_", new[] { AddressKeys.Labels.SFX }),
|
||||
("AUD_", new[] { AddressKeys.Labels.BGM }), // 未细分音频默认归 BGM
|
||||
("Scene_", Array.Empty<string>()), // 除 MainMenu 外场景无 label
|
||||
// ── 场景(除 MainMenu 外无 label,由 ExactLabelMap 特殊处理)──────
|
||||
("Scene_", Array.Empty<string>()),
|
||||
// ── 玩家 & 武器 ──────────────────────────────────────────────────
|
||||
("PLY_", new[] { AddressKeys.Labels.Preload }),
|
||||
("WPN_", new[] { AddressKeys.Labels.Weapon, AddressKeys.Labels.Preload }),
|
||||
// ── 敌人 & 投射物 ────────────────────────────────────────────────
|
||||
("ENM_", new[] { AddressKeys.Labels.Enemy }),
|
||||
("PROJ_", new[] { AddressKeys.Labels.Poolable, AddressKeys.Labels.Preload }),
|
||||
// ── 特效 & UI ────────────────────────────────────────────────────
|
||||
("VFX_", new[] { AddressKeys.Labels.Poolable, AddressKeys.Labels.Preload }),
|
||||
("UI_", Array.Empty<string>()), // 除 FloatingDamageText 外 UI 无默认 label
|
||||
// ── 收集物 ──────────────────────────────────────────────────────
|
||||
("COL_", new[] { AddressKeys.Labels.Poolable, AddressKeys.Labels.Preload }),
|
||||
// ── 配置数据 ─────────────────────────────────────────────────────
|
||||
("CHM_", new[] { AddressKeys.Labels.Charms }),
|
||||
("MAP_", new[] { AddressKeys.Labels.Config }), // 地图数据 SO 为动态加载配置
|
||||
("Config/", new[] { AddressKeys.Labels.Config }),
|
||||
// ── 技能 / 法术 / 能力 / 世界物件 / 持久化:无批量加载需求,不加 Label ──
|
||||
("SKL_", Array.Empty<string>()),
|
||||
("SPL_", Array.Empty<string>()),
|
||||
("ABL_", Array.Empty<string>()),
|
||||
("WLD_", Array.Empty<string>()),
|
||||
("SYS_", Array.Empty<string>()),
|
||||
};
|
||||
|
||||
// ── 公开 API ───────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user