using UnityEditor; using UnityEngine; using System.Collections.Generic; namespace LocalRank { public static class RankEditorTool { // 动态获取 GameId 列表 private static List GameIds => RankService.GetAllGameIds(); // 自定义 GameId 列表 private static readonly List CustomGameIds = new List { 1, 13, 14, 15, 16 }; [MenuItem("Tools/排行榜/创建排行榜表")] public static void CreateAllRankTables() { foreach (var gameId in CustomGameIds) { RankService.CreateTableIfNotExists(gameId); Debug.Log($"已创建排行榜表:rank_game_{gameId}"); } EditorUtility.DisplayDialog("操作完成", "已创建所有排行榜表", "好的"); } [MenuItem("Tools/排行榜/清空所有排行榜表")] public static void ClearAllRankTables() { if (!EditorUtility.DisplayDialog("警告", "你确定要清空所有排行榜数据吗?此操作不可撤销!", "确定", "取消")) return; foreach (var gameId in GameIds) { RankService.ClearTable(gameId); Debug.Log($"已清空排行榜表:rank_game_{gameId}"); } EditorUtility.DisplayDialog("操作完成", "已清空所有排行榜表数据", "好的"); } [MenuItem("Tools/排行榜/打印所有排行榜数据")] public static void PrintAllRanks() { foreach (var gameId in GameIds) { var (list, _, count) = RankService.GetRankList(gameId, -1); Debug.Log($"[rank_game_{gameId}] 总记录数:{count}"); foreach (var entry in list) { Debug.Log($"[{entry.Rank}] {entry.Nickname} - {entry.Score} {(entry.IsSelf ? "(自己)" : "")}"); } } EditorUtility.DisplayDialog("打印完成", "已在控制台输出所有排行榜数据", "好的"); } } }