mcpField
U
unity-debug

unity-debug

github.com/besty0728开发1.9k83 次安装今天更新
代码仓库

关于 unity-debug

unity-debug 是一组用于排查 Unity 编辑器错误和收集诊断信息的技能,面向开发与故障排查流程。它将编辑器健康快照、控制台日志、编译状态及系统信息等检查集中在一起。

主要功能

  1. 01汇总编辑器健康状态
  2. 02筛选控制台日志和错误
  3. 03检查编译状态与结果
  4. 04获取堆栈、程序集和系统信息
  5. 05请求重编译并设置定义符号

适用场景

  1. 01改动后检查控制台错误
  2. 02诊断脚本编译失败
  3. 03收集 Unity 环境信息
  4. 04查看错误条目的堆栈跟踪

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/besty0728/unity-skills --skill unity-debug

安装后在 Claude Code 中输入/unity-debug确认已加载。

详细介绍

**调用本模块中的任何技能前:**如果你打算根据技能名称或描述猜测参数后调用该技能,请停下——先阅读此文件(或通过 GET /skills/recommend?includeSchema=true 获取其架构)。如果你已从 recommend/schema 获取参数定义,则可直接进行 dryRun。

触发条件

  • 诊断编译失败
  • 改动后检查报错
  • 强制重编
  • 收集系统诊断
  • 诊断编译失败、改动后检查报错、强制重编、收集系统诊断

调试技能

用于检查错误和诊断的实用工具。

运行模式

  • Approval:只读类技能(unity_diagnose / debug_get_errors / debug_get_logs / debug_check_compilation / debug_get_system_info / debug_get_stack_trace / debug_get_assembly_info / debug_get_defines / debug_get_memory_info,全部标记为 SkillMode.SemiAuto)直接执行;debug_force_recompile / debug_set_defines 默认标记为 SkillMode.FullAuto,需要用户授权;授权后一步执行并返回结果。
  • Auto / Bypass:直接执行。
  • 本模块包含 Reload 类高危技能:debug_force_recompile(标记为 MayTriggerReload=true)必然触发 Domain Reload;debug_set_defines 修改 PlayerSettings 的 scripting defines 也会触发重编译——这些技能在 Approval / Auto 下会被 IsForbiddenInSemi 自动拦截,仅在 Bypass 或 Allowlist 命中时可执行;调用后服务端会短暂不可用。

禁止(常见幻觉):

  • debug_compile / debug_recompile 不存在 → 使用 debug_force_recompile
  • debug_run 不存在 → 使用 editor_play(editor 模块)
  • debug_clear 不存在 → 使用 console_clear(console 模块)
  • debug_set_defines 会触发 Domain Reload——服务端将暂时不可用

路由:

  • 对于运行时控制台日志 → 使用 console 模块的 console_get_logs / console_start_capture
  • 对于播放模式控制 → 使用 editor 模块
  • 对于脚本编译反馈 → 使用 script 模块的 script_get_compile_feedback

技能

unity_diagnose

编辑器健康状况汇总快照——问题排查时首先调用此技能。 在单次响应中汇总控制台错误、编译状态、近期工作流任务、近期作业和服务端统计信息。无需串联调用 4-5 个单独技能。

参数:

  • errorLimit (int,可选,默认值 20,范围 1-200):返回的控制台条目数上限。
  • includeWarnings (bool,可选,默认值 true):是否包含警告(false = 仅错误)。
  • includeRecentJobs (bool,可选,默认值 true):是否包含最近 10 个异步作业。

返回: { summary: { healthy, consoleErrorCount, consoleWarningCount, isCompiling, serverRunning, hint }, compile, console, workflow, server, recentJobs }

debug_get_logs

获取按类型和内容筛选的控制台日志。 参数:

  • type (string,可选):按类型筛选(Error/Warning/Log/All,不区分大小写;若值不属于其中任何一种,将以 SEMANTIC_INVALID 拒绝)。默认值:Error。
  • filter (string,可选):按内容筛选。
  • limit (int,可选):条目数上限。默认值:50。
debug_get_errors

仅获取控制台中的活动错误和异常。 参数:

  • limit (int,可选):条目数上限。默认值:50。
debug_check_compilation

检查 Unity 当前是否正在编译,以及上次已完成的编译是否成功。 **参数:**无。 返回:{isCompiling, isUpdating, lastCompilation: {succeeded, errorCount, finishedAtUtc, errors: [{file, line, message}]}}——在此编辑器会话中完成编译前,lastCompilation 为 null。仅凭 isCompiling: false 绝不代表上次编译成功:编译失败后,Unity 会继续运行旧程序集。

debug_force_recompile

请求进行一次干净的脚本编译,并返回 status:"accepted"、jobId 和 waitUrl。GET 该任务,验证其对应周期已成功编译程序集并加载新域(resultData.compilation.compiled、success、domainLoaded)。请求 Unity 的 CleanBuildCache 本身并不能证明程序集已编译:请求周期为空时会因 no_compilation 失败。验证脚本变更时,请使用实际脚本修改所触发的编译任务。Unity 可能会将请求推迟到退出 Play Mode 后处理,且该任务永远不会自动退出 Play Mode。 **参数:**无。

debug_get_system_info

获取系统和 Unity 环境信息。 **参数:**无。

debug_get_stack_trace

根据日志条目索引获取堆栈跟踪。

参数类型必填默认值说明
entryIndexint是-要获取堆栈跟踪的日志条目索引

返回:{ index, message, stackTrace }

debug_get_assembly_info

获取项目程序集信息。

**参数:**无。

返回:{ success, count, assemblies }

debug_get_defines

获取当前平台的脚本定义符号。

**参数:**无。

返回:{ success, buildTargetGroup, defines }

debug_set_defines

设置当前平台的脚本定义符号。

参数类型必填默认值说明
definesstring是-要设置的脚本定义符号

返回:{ success, buildTargetGroup, defines, serverAvailability }

debug_get_memory_info

获取内存使用信息。

**参数:**无。

返回:{ success, totalAllocatedMB, totalReservedMB, totalUnusedReservedMB, monoUsedSizeMB, monoHeapSizeMB }


精确签名

精确的名称、参数、默认值和返回值由 GET /skills/schema 或 unity_skills.get_skill_schema() 定义,而非本文件。

评论

支持 Markdown