SuperAPI AI 工具集

unity-script

编程与开发

查看项目

更新于 10-15 17:25

技能介绍

用途:在 Unity 项目里创建、读取、编辑、搜索、重构和检查 C# 脚本,并获取编译结果。

主要能力分两类。只读类(SemiAuto 下任何模式直接运行):script_read、script_list、script_find_in_file、script_get_info、script_get_compile_feedback。写入类共 7 个:script_create、script_create_batch、script_replace、script_append、script_rename、script_move、script_delete,均标记 MayTriggerReload 与高风险,NeverInSemi:Approval 与 Auto 返回 MODE_FORBIDDEN,仅 Bypass 或命中 Allowlist 才运行,不应为其申请授权。

使用方式:参数以 schema 为准(建议 includeSchema=true 或 /skills/schema?names=)。脚本名是文件与类名,不带 .cs 和路径分隔符;路径为项目相对路径,以 Assets/ 或 Packages/ 开头,缺失文件夹会被创建。script_create 有 content 时按原文写入,否则按模板填充,支持 MonoBehaviour、ScriptableObject、Editor、EditorWindow 四种,可加 namespaceName;MonoBehaviour/ScriptableObject 需类名等于文件名才绑定。多个新脚本用 script_create_batch 以减少域重载。写入立即返回 {success, status:"accepted", path, jobId, waitUrl, serverAvailability},随后编译,域重载期间服务短暂不可达。查询编译结果 GET 返回的 waitUrl,例如 curl -s --retry 20 --retry-connrefused --retry-all-errors --retry-delay 2 "http://localhost:<port>/jobs/<jobId>?wait=90",完成或失败时返回 resultData.compilation(isCompiling、hasErrors、errorCount、errors)。也可用 script_get_compile_feedback(scriptPath)。checkCompile: false 跳过诊断,diagnosticLimit 默认 20。

限制与注意:已有文件不会被覆盖;存在文件时提示 Script already exists。script_rename 只改文件名、不改类名。不存在 script_edit、script_update、script_write;修改已有文件用 script_replace。已编译脚本的 API 分析属于 script_analyze。常见错误含 MISSING_PARAM、SEMANTIC_INVALID、TARGET_NOT_FOUND、SKILL_ERROR。官方未提供更细致的返回结构说明。