[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FF99B1DV7RDAY98QVFFMA9":3,"skill-same:01M7FF99B1DV7RDAY98QVFFMA9":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7FF99B1DV7RDAY98QVFFMA9","unity-csharp-scripting",null,"Write Unity 6.3 LTS C# gameplay scripts: the MonoBehaviour lifecycle (Awake\u002FOnEnable\u002FStart\u002FUpdate\u002FFixedUpdate\u002FLateUpdate), GameObject and component access, coroutines, and Inspector serialization. Use when creating or editing .cs scripts in a Unity project, or when the user mentions MonoBehaviour, Start\u002FUpdate, GetComponent, SerializeField, coroutines, or \"Unity script\".","heynemann\u002Fdotfiles-stow","heynemann","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F60965?v=4","01M7DFBD9ZDB2J2QE7R4AR0PES","Bernardo Heynemann","01M7FERV0J6GMQ0RHEH6EHGYRW",0,"MIT","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-csharp-scripting\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: unity-csharp-scripting\ndescription: >\n  Write Unity 6.3 LTS C# gameplay scripts: the MonoBehaviour lifecycle\n  (Awake\u002FOnEnable\u002FStart\u002FUpdate\u002FFixedUpdate\u002FLateUpdate), GameObject and component\n  access, coroutines, and Inspector serialization. Use when creating or editing .cs\n  scripts in a Unity project, or when the user mentions MonoBehaviour, Start\u002FUpdate,\n  GetComponent, SerializeField, coroutines, or \"Unity script\".\n---\n\n# Unity C# Scripting (MonoBehaviour)\n\nWrite correct, idiomatic gameplay scripts in Unity 6. Get the lifecycle, component\naccess, serialization, and coroutines right so behaviour is deterministic and the\nInspector stays useful. Targets **Unity 6.3 LTS (6000.3)**, C# \u002F .NET Standard 2.1.\n\n## When to use\n\n- Use when authoring or fixing a `MonoBehaviour`: choosing the right lifecycle callback,\n  reading\u002Fcaching components, exposing fields to the Inspector, or running timed logic\n  with coroutines.\n- Use when the project has `*.cs` files, an `Assembly-CSharp` or `*.asmdef`, and a\n  `ProjectSettings\u002F` folder.\n\n**When *not* to use:** moving rigidbodies \u002F collision response → `unity-physics`; reading\nplayer input → `unity-input-system`; shared data assets \u002F config → `unity-scriptableobjects`;\nAnimator parameters → `unity-animation`. This skill owns the *script lifecycle and C#\nplumbing*, not those subsystems.\n\n## Core workflow\n\n1. **Pick the callback by purpose, not habit.** `Awake` (cache references, runs once on\n   load), `OnEnable` (subscribe to events), `Start` (init that depends on other objects'\n   `Awake`), `Update` (per-frame logic\u002Finput polling), `FixedUpdate` (physics), `LateUpdate`\n   (camera follow after movement), `OnDisable`\u002F`OnDestroy` (unsubscribe\u002Fcleanup).\n2. **Cache component lookups in `Awake`** — never call `GetComponent` every frame.\n3. **Expose tunables with `[SerializeField] private`**, not public fields, so other code\n   can't mutate them but designers can edit them in the Inspector.\n4. **Scale per-frame values by `Time.deltaTime`** in `Update` (and `Time.fixedDeltaTime`\n   semantics are automatic in `FixedUpdate`).\n5. **Use coroutines for time-sequenced logic** (delays, tweens, \"do X then wait then Y\");\n   start them with `StartCoroutine` and stop them deterministically.\n6. **Verify in Play mode**: check the Console for null-reference exceptions, confirm values\n   in the Inspector update as expected, and watch the Profiler if `Update` is hot.\n\n## Patterns\n\n### 1. Lifecycle + cached components (the canonical skeleton)\n\n```csharp\nusing UnityEngine;\n\n[RequireComponent(typeof(Rigidbody))]      \u002F\u002F auto-adds the dependency, prevents null refs\npublic class PlayerController : MonoBehaviour\n{\n    [SerializeField] private float moveSpeed = 6f;   \u002F\u002F editable in Inspector, private in code\n    private Rigidbody _rb;                            \u002F\u002F cached, not fetched per frame\n\n    private void Awake() => _rb = GetComponent\u003CRigidbody>();  \u002F\u002F cache once on load\n\n    private void Update()\n    {\n        \u002F\u002F Per-frame, non-physics work. Scale by deltaTime so it is frame-rate independent.\n        transform.Rotate(0f, 90f * Time.deltaTime, 0f);\n    }\n\n    private void FixedUpdate()\n    {\n        \u002F\u002F Physics work belongs here (fixed timestep). See the unity-physics skill.\n        _rb.MovePosition(_rb.position + transform.forward * moveSpeed * Time.fixedDeltaTime);\n    }\n}\n```\n\n### 2. Safe component access with `TryGetComponent`\n\n```csharp\n\u002F\u002F Avoids allocating a null and is clearer than GetComponent + null check.\nif (other.TryGetComponent\u003CHealth>(out var health))\n    health.Apply(-10);\n```\n\n### 3. Serialization that shows up correctly in the Inspector\n\n```csharp\n[SerializeField, Range(0f, 1f)] private float volume = 0.8f;  \u002F\u002F slider\n[SerializeField] private string playerName = \"Hero\";          \u002F\u002F private but serialized\n\n[System.Serializable]                 \u002F\u002F REQUIRED for a plain class to serialize\u002Fshow\npublic class Stats { public int hp = 100; public int mana = 50; }\n\n[SerializeField] private Stats stats = new();  \u002F\u002F nested struct-like data in the Inspector\n```\n\n### 4. Coroutines for time-sequenced logic\n\n```csharp\nprivate void Start() => StartCoroutine(FlashThenHide());\n\nprivate System.Collections.IEnumerator FlashThenHide()\n{\n    yield return new WaitForSeconds(0.5f);   \u002F\u002F wait half a second of game time\n    GetComponent\u003CRenderer>().enabled = false;\n    yield return null;                       \u002F\u002F resume next frame\n}\n```\n\n## Pitfalls\n\n- **`GetComponent` in `Update`** — it searches every frame and tanks performance. Cache the\n  reference in `Awake`\u002F`Start`.\n- **Physics in `Update`** — moving a `Rigidbody` with forces or `MovePosition` outside\n  `FixedUpdate` causes jitter and timestep-dependent behaviour. Read input in `Update`,\n  apply physics in `FixedUpdate`.\n- **Relying on `Start` order across objects** — `Start` runs after *all* `Awake`s, but order\n  among `Start`s is undefined. Do cross-object wiring in `Start`, self-setup in `Awake`.\n- **`public` fields just to show them in the Inspector** — that also lets any script mutate\n  them. Use `[SerializeField] private` instead.\n- **`gameObject.tag == \"Enemy\"`** allocates a string and is slower; use\n  `gameObject.CompareTag(\"Enemy\")`.\n- **Coroutines stop when the GameObject is disabled** — a disabled object's coroutines are\n  killed; re-`StartCoroutine` in `OnEnable` if it must survive toggling.\n- **`Update` never runs before `Start`, but the *first* `Update` can run on the same\n  frame as `Start`** — guard against not-yet-initialised fields if you split setup oddly.\n\n## References\n\n- For the full event-execution-order table and advanced coroutine patterns (custom\n  `CustomYieldInstruction`, stopping by handle, `WaitUntil`\u002F`WaitWhile`), read\n  `references\u002Flifecycle-and-coroutines.md`.\n- Primary docs: Unity Manual \"Event function execution order\"\n  (`https:\u002F\u002Fdocs.unity3d.com\u002FManual\u002Fexecution-order.html`) and `ScriptReference\u002FMonoBehaviour`.\n\n## Related skills\n\n- `unity-physics` — `Rigidbody`, collisions, and `FixedUpdate` motion.\n- `unity-input-system` — reading player input into these scripts.\n- `unity-scriptableobjects` — sharing data\u002Fconfig between scripts without singletons.\n","# Unity C# Scripting (MonoBehaviour)\n\nWrite correct, idiomatic gameplay scripts in Unity 6. Get the lifecycle, component\naccess, serialization, and coroutines right so behaviour is deterministic and the\nInspector stays useful. Targets **Unity 6.3 LTS (6000.3)**, C# \u002F .NET Standard 2.1.\n\n## When to use\n\n- Use when authoring or fixing a `MonoBehaviour`: choosing the right lifecycle callback,\n  reading\u002Fcaching components, exposing fields to the Inspector, or running timed logic\n  with coroutines.\n- Use when the project has `*.cs` files, an `Assembly-CSharp` or `*.asmdef`, and a\n  `ProjectSettings\u002F` folder.\n\n**When *not* to use:** moving rigidbodies \u002F collision response → `unity-physics`; reading\nplayer input → `unity-input-system`; shared data assets \u002F config → `unity-scriptableobjects`;\nAnimator parameters → `unity-animation`. This skill owns the *script lifecycle and C#\nplumbing*, not those subsystems.\n\n## Core workflow\n\n1. **Pick the callback by purpose, not habit.** `Awake` (cache references, runs once on\n   load), `OnEnable` (subscribe to events), `Start` (init that depends on other objects'\n   `Awake`), `Update` (per-frame logic\u002Finput polling), `FixedUpdate` (physics), `LateUpdate`\n   (camera follow after movement), `OnDisable`\u002F`OnDestroy` (unsubscribe\u002Fcleanup).\n2. **Cache component lookups in `Awake`** — never call `GetComponent` every frame.\n3. **Expose tunables with `[SerializeField] private`**, not public fields, so other code\n   can't mutate them but designers can edit them in the Inspector.\n4. **Scale per-frame values by `Time.deltaTime`** in `Update` (and `Time.fixedDeltaTime`\n   semantics are automatic in `FixedUpdate`).\n5. **Use coroutines for time-sequenced logic** (delays, tweens, \"do X then wait then Y\");\n   start them with `StartCoroutine` and stop them deterministically.\n6. **Verify in Play mode**: check the Console for null-reference exceptions, confirm values\n   in the Inspector update as expected, and watch the Profiler if `Update` is hot.\n\n## Patterns\n\n### 1. Lifecycle + cached components (the canonical skeleton)\n\n```csharp\nusing UnityEngine;\n\n[RequireComponent(typeof(Rigidbody))]      \u002F\u002F auto-adds the dependency, prevents null refs\npublic class PlayerController : MonoBehaviour\n{\n    [SerializeField] private float moveSpeed = 6f;   \u002F\u002F editable in Inspector, private in code\n    private Rigidbody _rb;                            \u002F\u002F cached, not fetched per frame\n\n    private void Awake() => _rb = GetComponent\u003CRigidbody>();  \u002F\u002F cache once on load\n\n    private void Update()\n    {\n        \u002F\u002F Per-frame, non-physics work. Scale by deltaTime so it is frame-rate independent.\n        transform.Rotate(0f, 90f * Time.deltaTime, 0f);\n    }\n\n    private void FixedUpdate()\n    {\n        \u002F\u002F Physics work belongs here (fixed timestep). See the unity-physics skill.\n        _rb.MovePosition(_rb.position + transform.forward * moveSpeed * Time.fixedDeltaTime);\n    }\n}\n```\n\n### 2. Safe component access with `TryGetComponent`\n\n```csharp\n\u002F\u002F Avoids allocating a null and is clearer than GetComponent + null check.\nif (other.TryGetComponent\u003CHealth>(out var health))\n    health.Apply(-10);\n```\n\n### 3. Serialization that shows up correctly in the Inspector\n\n```csharp\n[SerializeField, Range(0f, 1f)] private float volume = 0.8f;  \u002F\u002F slider\n[SerializeField] private string playerName = \"Hero\";          \u002F\u002F private but serialized\n\n[System.Serializable]                 \u002F\u002F REQUIRED for a plain class to serialize\u002Fshow\npublic class Stats { public int hp = 100; public int mana = 50; }\n\n[SerializeField] private Stats stats = new();  \u002F\u002F nested struct-like data in the Inspector\n```\n\n### 4. Coroutines for time-sequenced logic\n\n```csharp\nprivate void Start() => StartCoroutine(FlashThenHide());\n\nprivate System.Collections.IEnumerator FlashThenHide()\n{\n    yield return new WaitForSeconds(0.5f);   \u002F\u002F wait half a second of game time\n    GetComponent\u003CRenderer>().enabled = false;\n    yield return null;                       \u002F\u002F resume next frame\n}\n```\n\n## Pitfalls\n\n- **`GetComponent` in `Update`** — it searches every frame and tanks performance. Cache the\n  reference in `Awake`\u002F`Start`.\n- **Physics in `Update`** — moving a `Rigidbody` with forces or `MovePosition` outside\n  `FixedUpdate` causes jitter and timestep-dependent behaviour. Read input in `Update`,\n  apply physics in `FixedUpdate`.\n- **Relying on `Start` order across objects** — `Start` runs after *all* `Awake`s, but order\n  among `Start`s is undefined. Do cross-object wiring in `Start`, self-setup in `Awake`.\n- **`public` fields just to show them in the Inspector** — that also lets any script mutate\n  them. Use `[SerializeField] private` instead.\n- **`gameObject.tag == \"Enemy\"`** allocates a string and is slower; use\n  `gameObject.CompareTag(\"Enemy\")`.\n- **Coroutines stop when the GameObject is disabled** — a disabled object's coroutines are\n  killed; re-`StartCoroutine` in `OnEnable` if it must survive toggling.\n- **`Update` never runs before `Start`, but the *first* `Update` can run on the same\n  frame as `Start`** — guard against not-yet-initialised fields if you split setup oddly.\n\n## References\n\n- For the full event-execution-order table and advanced coroutine patterns (custom\n  `CustomYieldInstruction`, stopping by handle, `WaitUntil`\u002F`WaitWhile`), read\n  `references\u002Flifecycle-and-coroutines.md`.\n- Primary docs: Unity Manual \"Event function execution order\"\n  (`https:\u002F\u002Fdocs.unity3d.com\u002FManual\u002Fexecution-order.html`) and `ScriptReference\u002FMonoBehaviour`.\n\n## Related skills\n\n- `unity-physics` — `Rigidbody`, collisions, and `FixedUpdate` motion.\n- `unity-input-system` — reading player input into these scripts.\n- `unity-scriptableobjects` — sharing data\u002Fconfig between scripts without singletons.\n",{"name":5,"description":7},"main","e4d0a0940fd53fc8a3a1e1dcb967c0a18ea8ba0f","omp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-csharp-scripting","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow","https:\u002F\u002Fgithub.com\u002Fheynemann","http:\u002F\u002Fwww.thumbor.org","CTO @ Flutter Brazil | Former Meta & Coinbase","2026-10-29 20:46:15",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add heynemann\u002Fdotfiles-stow --skill unity-csharp-scripting",{"tool":38,"command":39},"bunx","bunx skills add heynemann\u002Fdotfiles-stow --skill unity-csharp-scripting",{"tool":41,"command":42},"pnpm","pnpm dlx skills add heynemann\u002Fdotfiles-stow --skill unity-csharp-scripting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-csharp-scripting\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Flifecycle-and-coroutines.md","REFERENCE","参考文档",4257,"https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-csharp-scripting\u002Freferences\u002Flifecycle-and-coroutines.md",[53,60,67,74,81,88],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7FFA0PAN04C2DVK6A7CXK6K","unity-scriptableobjects","Architect Unity 6.3 LTS data and decoupling with ScriptableObjects: config\u002Fdata assets, shared runtime variables, event channels, and runtime sets\u002Fregistries. Use when designing data-driven systems, replacing singletons\u002Fmanagers, creating .asset data with CreateAssetMenu, or when the user mentions ScriptableObject, SO architecture, or data assets.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-scriptableobjects\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7FF9SPKA8BC4EGCHJGGJK5P","unity-package-management","Adds, removes, upgrades, and discovers Unity (UPM) packages from outside the Editor. Use for headless or CI package installs, verifying package IDs and versions, or choosing which packages a game needs. The Unity CLI doesn't manage packages.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-package-management\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7FF9KBCKR352R6ZSY2BB2J3","unity-input-system","Wire player input in Unity 6.3 LTS with the Input System package: Input Actions, action maps, the PlayerInput component, and reading values via callbacks or polling. Use when the project has a .inputactions asset or com.unity.inputsystem, or when the user mentions the Unity Input System, InputAction, action maps, PlayerInput, control schemes, or rebinding.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-input-system\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7FF9FREKNGB4PQP8ZHTN1D8","unity-ecs-patterns","Master Unity ECS (Entity Component System) with DOTS, Jobs, and Burst for high-performance game development. Use when building data-oriented games, optimizing performance, or working with large entity counts.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-ecs-patterns\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7FF8ZK7PAPR4QZ44SY9ZDAJ","unity-cli","Controls the Unity Editor and projects from the command line, driving a running Editor to edit scenes and assets or run C#. Use when asked to install or manage Editors, licenses, or projects, set up version control, build, test, configure the Unity MCP server, or run any unity command.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Funity-cli\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7FF8RW28TPAJWF8FQPMA105","to-tickets","Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker (edges as text in one file per ticket locally, or native blocking links on a real tracker).","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fdotfiles-stow\u002Fblob\u002Fmain\u002Fomp\u002F.omp\u002Fprofiles\u002Funity\u002Fskills-sh\u002F.agents\u002Fskills\u002Fto-tickets\u002FSKILL.md",[],[]]