[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79QHMF9SR5D0KNCX8Z49DP1":3,"skill-same:01M79QHMF9SR5D0KNCX8Z49DP1":51},{"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":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M79QHMF9SR5D0KNCX8Z49DP1","unity-scriptableobjects",null,"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.","JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funity-scriptableobjects\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: unity-scriptableobjects\ndescription: >\n  Architect Unity 6.3 LTS data and decoupling with ScriptableObjects: config\u002Fdata assets, shared\n  runtime variables, event channels, and runtime sets\u002Fregistries. Use when designing\n  data-driven systems, replacing singletons\u002Fmanagers, creating .asset data with\n  CreateAssetMenu, or when the user mentions ScriptableObject, SO architecture, or data assets.\n---\n\n# Unity ScriptableObject Architecture\n\nUse `ScriptableObject` assets to store shared data and decouple systems in Unity 6.3 LTS —\nconfiguration, event channels, and registries that live as project assets instead of being\nhard-wired into scenes or singletons. Targets **Unity 6.3 LTS (6000.3)**.\n\n## When to use\n\n- Use when you need designer-editable config (weapon stats, level data), to share one value\n  between unrelated systems, to decouple senders from listeners via event channels, or to\n  build a runtime registry of active objects — without a `static`\u002Fsingleton manager.\n- Use when the project has `*.asset` data files backed by `: ScriptableObject` classes.\n\n**When _not_ to use:** per-instance runtime state that differs per GameObject (that belongs on\na MonoBehaviour) — a ScriptableObject asset is _shared_ by everyone who references it. Saving\nplayer progress to disk → `save-systems`. Plain DTOs that never need to be an asset can just be\n`[System.Serializable]` classes.\n\n## Core workflow\n\n1. **Define the class** deriving from `ScriptableObject` and tag it with `[CreateAssetMenu]` so\n   designers can create instances from the Assets menu.\n2. **Create one or more `.asset` instances** in the Project window; each is a shared, named\n   piece of data referenced by `[SerializeField]` fields.\n3. **Reference, don't copy.** MonoBehaviours hold a reference to the asset; they all see the\n   same data, so changing the asset changes every consumer.\n4. **For decoupling**, model _signals_ and _shared variables_ as ScriptableObjects: a\n   \"FloatVariable\" the HUD reads and the player writes; an \"event channel\" the player raises\n   and many systems listen to. Neither side references the other.\n5. **Reset runtime mutations** in `OnEnable` if the asset is mutated during play, because edits\n   made in the Editor at runtime persist on the asset (a frequent source of \"my values\n   changed after I played\").\n6. **Verify** by inspecting the asset values during Play mode and confirming consumers react.\n\n## Patterns\n\n### 1. Config\u002Fdata asset\n\n```csharp\nusing UnityEngine;\n\n[CreateAssetMenu(fileName = \"WeaponData\", menuName = \"Game\u002FWeapon Data\", order = 0)]\npublic class WeaponData : ScriptableObject\n{\n    public string displayName = \"Pistol\";\n    public int    damage = 10;\n    public float  fireRate = 0.25f;\n    public GameObject projectilePrefab;\n}\n```\n\n```csharp\npublic class Weapon : MonoBehaviour\n{\n    [SerializeField] private WeaponData data;   \u002F\u002F assign the shared asset in the Inspector\n    private void Fire() => Debug.Log($\"{data.displayName} for {data.damage}\");\n}\n```\n\n### 2. Shared runtime variable (decouples producer from consumer)\n\n```csharp\n[CreateAssetMenu(menuName = \"Game\u002FFloat Variable\")]\npublic class FloatVariable : ScriptableObject\n{\n    [SerializeField] private float initialValue;\n    [System.NonSerialized] public float runtimeValue;   \u002F\u002F not saved to the asset\n\n    private void OnEnable()\n    {\n        runtimeValue = initialValue;                    \u002F\u002F reset when the asset loads\n#if UNITY_EDITOR\n        \u002F\u002F With Reload Domain off, OnEnable does not run again on Play, so also reset there.\n        UnityEditor.EditorApplication.playModeStateChanged -= ResetOnPlay;\n        UnityEditor.EditorApplication.playModeStateChanged += ResetOnPlay;\n#endif\n    }\n\n#if UNITY_EDITOR\n    private void OnDisable() => UnityEditor.EditorApplication.playModeStateChanged -= ResetOnPlay;\n\n    private void ResetOnPlay(UnityEditor.PlayModeStateChange change)\n    {\n        if (change == UnityEditor.PlayModeStateChange.ExitingEditMode) runtimeValue = initialValue;\n    }\n#endif\n}\n\u002F\u002F Player writes playerHealth.runtimeValue; the HUD reads it — neither references the other.\n```\n\n### 3. Creating an instance at runtime (not an asset on disk)\n\n```csharp\n\u002F\u002F For transient SO data you build in code (e.g. a generated config).\nvar temp = ScriptableObject.CreateInstance\u003CWeaponData>();\ntemp.damage = 25;\n\u002F\u002F ...use temp...  Destroy(temp);   \u002F\u002F clean up runtime-created instances\n```\n\n## Pitfalls\n\n- **Editing an SO at runtime persists in the Editor** — values you change during Play stay\n  changed on the asset after you stop. Keep mutable runtime state in `[NonSerialized]` fields\n  reset in `OnEnable`, or it will surprise you. (In a _build_, asset edits do not persist\n  across launches.)\n- **Disabled Domain Reload skips your `OnEnable` reset** — with **Enter Play Mode Options**\n  enabled and **Reload Domain** off (a Unity 6.3 LTS fast-iteration setting), already-loaded SOs are\n  _not_ re-created when you press Play, so `OnEnable` never fires and `runtimeValue` keeps its\n  value from the previous session (non-serialized fields keep their Play-mode values). Also\n  reset on `EditorApplication.playModeStateChanged` (pattern 2), or from a static\n  `[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]` method.\n- **Expecting per-object state** — every reference points to the _same_ asset. If two enemies\n  need different current HP, store HP on the MonoBehaviour, not the shared SO.\n- **No frame lifecycle** — ScriptableObjects have `OnEnable`\u002F`OnDisable`\u002F`OnDestroy` but no\n  `Update`. Don't expect per-frame callbacks.\n- **Using SOs as a save file** — they're authoring assets, not runtime persistence; write\n  progress with `save-systems` instead.\n- **Leaking `CreateInstance` objects** — runtime-created instances are not garbage-collected\n  like plain C# objects; `Destroy` them when done.\n\n## References\n\n- For the **event-channel** pattern (a `GameEvent` SO + listeners, type-safe payloads) and\n  **runtime sets\u002Fregistries** (a shared list of active enemies), read\n  `references\u002Fevent-channels.md`.\n- Primary docs: Unity Manual \"ScriptableObject\" (`\u002FManual\u002Fclass-ScriptableObject.html`) and\n  \"Enter Play mode with domain reload disabled\" (`\u002FManual\u002Fdomain-reloading.html`), plus\n  `ScriptReference\u002FScriptableObject`, `ScriptReference\u002FCreateAssetMenuAttribute`.\n\n## Related skills\n\n- `unity-csharp-scripting` — the MonoBehaviours that consume these assets.\n- `save-systems` — persisting state to disk (what SOs are _not_ for).\n- `card-game` \u002F `rpg` \u002F `survival-crafting` — genres that lean on SO-driven data.\n","# Unity ScriptableObject Architecture\n\nUse `ScriptableObject` assets to store shared data and decouple systems in Unity 6.3 LTS —\nconfiguration, event channels, and registries that live as project assets instead of being\nhard-wired into scenes or singletons. Targets **Unity 6.3 LTS (6000.3)**.\n\n## When to use\n\n- Use when you need designer-editable config (weapon stats, level data), to share one value\n  between unrelated systems, to decouple senders from listeners via event channels, or to\n  build a runtime registry of active objects — without a `static`\u002Fsingleton manager.\n- Use when the project has `*.asset` data files backed by `: ScriptableObject` classes.\n\n**When _not_ to use:** per-instance runtime state that differs per GameObject (that belongs on\na MonoBehaviour) — a ScriptableObject asset is _shared_ by everyone who references it. Saving\nplayer progress to disk → `save-systems`. Plain DTOs that never need to be an asset can just be\n`[System.Serializable]` classes.\n\n## Core workflow\n\n1. **Define the class** deriving from `ScriptableObject` and tag it with `[CreateAssetMenu]` so\n   designers can create instances from the Assets menu.\n2. **Create one or more `.asset` instances** in the Project window; each is a shared, named\n   piece of data referenced by `[SerializeField]` fields.\n3. **Reference, don't copy.** MonoBehaviours hold a reference to the asset; they all see the\n   same data, so changing the asset changes every consumer.\n4. **For decoupling**, model _signals_ and _shared variables_ as ScriptableObjects: a\n   \"FloatVariable\" the HUD reads and the player writes; an \"event channel\" the player raises\n   and many systems listen to. Neither side references the other.\n5. **Reset runtime mutations** in `OnEnable` if the asset is mutated during play, because edits\n   made in the Editor at runtime persist on the asset (a frequent source of \"my values\n   changed after I played\").\n6. **Verify** by inspecting the asset values during Play mode and confirming consumers react.\n\n## Patterns\n\n### 1. Config\u002Fdata asset\n\n```csharp\nusing UnityEngine;\n\n[CreateAssetMenu(fileName = \"WeaponData\", menuName = \"Game\u002FWeapon Data\", order = 0)]\npublic class WeaponData : ScriptableObject\n{\n    public string displayName = \"Pistol\";\n    public int    damage = 10;\n    public float  fireRate = 0.25f;\n    public GameObject projectilePrefab;\n}\n```\n\n```csharp\npublic class Weapon : MonoBehaviour\n{\n    [SerializeField] private WeaponData data;   \u002F\u002F assign the shared asset in the Inspector\n    private void Fire() => Debug.Log($\"{data.displayName} for {data.damage}\");\n}\n```\n\n### 2. Shared runtime variable (decouples producer from consumer)\n\n```csharp\n[CreateAssetMenu(menuName = \"Game\u002FFloat Variable\")]\npublic class FloatVariable : ScriptableObject\n{\n    [SerializeField] private float initialValue;\n    [System.NonSerialized] public float runtimeValue;   \u002F\u002F not saved to the asset\n\n    private void OnEnable()\n    {\n        runtimeValue = initialValue;                    \u002F\u002F reset when the asset loads\n#if UNITY_EDITOR\n        \u002F\u002F With Reload Domain off, OnEnable does not run again on Play, so also reset there.\n        UnityEditor.EditorApplication.playModeStateChanged -= ResetOnPlay;\n        UnityEditor.EditorApplication.playModeStateChanged += ResetOnPlay;\n#endif\n    }\n\n#if UNITY_EDITOR\n    private void OnDisable() => UnityEditor.EditorApplication.playModeStateChanged -= ResetOnPlay;\n\n    private void ResetOnPlay(UnityEditor.PlayModeStateChange change)\n    {\n        if (change == UnityEditor.PlayModeStateChange.ExitingEditMode) runtimeValue = initialValue;\n    }\n#endif\n}\n\u002F\u002F Player writes playerHealth.runtimeValue; the HUD reads it — neither references the other.\n```\n\n### 3. Creating an instance at runtime (not an asset on disk)\n\n```csharp\n\u002F\u002F For transient SO data you build in code (e.g. a generated config).\nvar temp = ScriptableObject.CreateInstance\u003CWeaponData>();\ntemp.damage = 25;\n\u002F\u002F ...use temp...  Destroy(temp);   \u002F\u002F clean up runtime-created instances\n```\n\n## Pitfalls\n\n- **Editing an SO at runtime persists in the Editor** — values you change during Play stay\n  changed on the asset after you stop. Keep mutable runtime state in `[NonSerialized]` fields\n  reset in `OnEnable`, or it will surprise you. (In a _build_, asset edits do not persist\n  across launches.)\n- **Disabled Domain Reload skips your `OnEnable` reset** — with **Enter Play Mode Options**\n  enabled and **Reload Domain** off (a Unity 6.3 LTS fast-iteration setting), already-loaded SOs are\n  _not_ re-created when you press Play, so `OnEnable` never fires and `runtimeValue` keeps its\n  value from the previous session (non-serialized fields keep their Play-mode values). Also\n  reset on `EditorApplication.playModeStateChanged` (pattern 2), or from a static\n  `[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]` method.\n- **Expecting per-object state** — every reference points to the _same_ asset. If two enemies\n  need different current HP, store HP on the MonoBehaviour, not the shared SO.\n- **No frame lifecycle** — ScriptableObjects have `OnEnable`\u002F`OnDisable`\u002F`OnDestroy` but no\n  `Update`. Don't expect per-frame callbacks.\n- **Using SOs as a save file** — they're authoring assets, not runtime persistence; write\n  progress with `save-systems` instead.\n- **Leaking `CreateInstance` objects** — runtime-created instances are not garbage-collected\n  like plain C# objects; `Destroy` them when done.\n\n## References\n\n- For the **event-channel** pattern (a `GameEvent` SO + listeners, type-safe payloads) and\n  **runtime sets\u002Fregistries** (a shared list of active enemies), read\n  `references\u002Fevent-channels.md`.\n- Primary docs: Unity Manual \"ScriptableObject\" (`\u002FManual\u002Fclass-ScriptableObject.html`) and\n  \"Enter Play mode with domain reload disabled\" (`\u002FManual\u002Fdomain-reloading.html`), plus\n  `ScriptReference\u002FScriptableObject`, `ScriptReference\u002FCreateAssetMenuAttribute`.\n\n## Related skills\n\n- `unity-csharp-scripting` — the MonoBehaviours that consume these assets.\n- `save-systems` — persisting state to disk (what SOs are _not_ for).\n- `card-game` \u002F `rpg` \u002F `survival-crafting` — genres that lean on SO-driven data.\n",{"name":5,"description":7},"main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Funity-scriptableobjects","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill unity-scriptableobjects",{"tool":37,"command":38},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill unity-scriptableobjects",{"tool":40,"command":41},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill unity-scriptableobjects","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funity-scriptableobjects\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fevent-channels.md","REFERENCE","参考文档",3924,"https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funity-scriptableobjects\u002Freferences\u002Fevent-channels.md",[52,58,64,70,76,82],{"skillNo":53,"name":54,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":6,"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},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]