Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill unity-csharpgit clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cnWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/unity-csharp)<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/unity-csharp"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/unity-csharp/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/unity-csharp"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/unity-csharp.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00028 | $0.02931 |
| Opus 5.5 | $0.00011 | $0.01172 |
| Sonnet 5.5 | $0.00006 | $0.00586 |
| Haiku 4.5 | $0.00003 | $0.00293 |
Grade A, and why
unity-csharp scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 198 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Unity C# 最佳实践
何时用
- 开始编写任何 Unity MonoBehaviour 或 ScriptableObject 脚本前。
- Review 他人 Unity C# 代码,发现有 Update 里调 GetComponent 或每帧 new 对象时。
- 接到性能优化任务:帧率抖动、GC Alloc 频繁、Profiler 里 Update 调用栈过深。
- 设计新的配置数据结构,考虑用 ScriptableObject 还是 public 字段时。
- 协程逻辑出现卡死、泄漏、或销毁对象后仍在跑的诡异现象时。
核心规则
1. 慎用 Update:每帧逻辑最小化
规则: Update 里只放真正需要每帧响应的逻辑;能用事件、协程或 InvokeRepeating 驱动的,就不放进 Update;任何 GetComponent、Find、tag 比较一律在 Awake/Start 里缓存,不在 Update 里调用。
为什么: AI 和新手最常见的模式是把所有逻辑堆进 Update——"反正每帧都会跑到"。结果是:GetComponent 每帧反射查找,100 个对象就是 100 次反射;倒计时用 timer -= Time.deltaTime 没问题,但 UI 刷新、动画触发、状态机判断全挤在里面,Profiler 一看 Update 占 80% CPU。更隐蔽的问题:新人把 FindObjectOfType<GameManager>() 放进 Update,场景里一有几十个对象就掉帧,排查时根本不知道从哪查。
怎么做:
- 初始化引用全部放
Awake(自身组件)或Start(跨对象引用)。 - 定时逻辑用
InvokeRepeating或协程WaitForSeconds,不用Update里的计数器模拟低频事件。 - 状态变化用 C# event / UnityEvent 通知,订阅方在变化时响应,而不是每帧 poll
if (state == X)。 - 真正需要每帧的(移动插值、输入读取),保留在 Update,但代码量要极简,复杂运算提取为方法并在注释说明频率必要性。
2. 防 GC 抖动:高频路径零分配
规则: Update、FixedUpdate、协程的热路径里禁止出现 new(含 LINQ、字符串拼接、装箱);高频复用的对象用对象池管理;容器在初始化时预分配容量。
为什么: Unity 使用 Mono / IL2CPP 的 GC,GC 触发时会造成明显的帧率刺尖(spike)。AI 写的代码里最常见的杀手:string.Format($"Score: {score}") 每帧执行一次,enemies.Where(e => e.isAlive).ToList() 每帧生成一个新 List,new Vector3(...) 看起来是值类型不会 GC——但装箱到 object 参数时就会。新手则喜欢在子弹生成时 Instantiate、销毁时 Destroy,百发子弹就是百次 GC 压力。
怎么做:
- 用
StringBuilder或TMP_Text.SetText(format, arg)替代字符串拼接。 - LINQ 仅用于编辑器工具或低频初始化代码,运行时热路径改用显式 for 循环。
- 子弹、特效、UI 元素用
ObjectPool<T>(Unity 2021+ 内置)或自实现的栈式对象池。 - 用
List<T>(initialCapacity)预分配,避免频繁扩容。 - 用 Unity Profiler 的 Memory 视图确认改动前后 GC Alloc 列清零。
3. 协程与生命周期:时序清楚,防泄漏
规则: 明确 Awake → OnEnable → Start → Update → OnDisable → OnDestroy 的时序;协程在对象 SetActive(false) 或 OnDisable 时自动停止,但 OnDestroy 时不会自动停止跑在其他 MonoBehaviour 上的协程;协程引用必须在 OnDisable/OnDestroy 里主动 StopCoroutine。
为什么: AI 最典型的错误:在 Awake 里启动协程并访问 Start 才会初始化完毕的跨组件引用,导致 NullReferenceException;或者在 OnDestroy 不清理,导致协程持有对已销毁对象的引用,每帧报 MissingReferenceException,但对象本体早就没了,难以溯源。新手则习惯用 StartCoroutine 后不记返回值,后来想停却只能 StopAllCoroutines,误杀其他协程。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 198 lines · 28 tokens per session scan A 4715e549708f
unity-csharp is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 5mo ago), licensed MIT. It adds 28 tokens to every session and 2,931 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
unity-csharp compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| unity-csharpWade-DevCode/awesome-coding-skills-cn | Skill | 7 | 5mo ago | MIT | A | 28 | Claude Code, Codex |
| bevy-ecs-rustfindscripter/everything-skills | Skill | 12 | today | none | A | 114 | Claude Code |
| stream-unityGetStream/agent-skills | Skill | 21 | yesterday | Apache-2.0 | A | 211 | Claude Code |
| game-developmentMindrally/skills | Skill | 323 | 1mo ago | Apache-2.0 | A | 23 | Claude Code |
| se-dev-game-codeCometWorks/skills | Skill | 12 | today | MIT | A | 67 | Claude Code |
| se-dev-scriptCometWorks/skills | Skill | 12 | today | MIT | A | 31 | Claude Code |
| unity-scriptbatihandev/unity-mcp-skills | Skill | 7 | 18d ago | MIT | A | 25 | Claude Code, Codex |