{"success":true,"name":"put-shared-unity-data-in-scriptableobjects-instead-of-duplic","description":"Unity values are hardcoded or copy-pasted across prefabs and scripts","category":"ai-brimind","path":"ai-brimind/put-shared-unity-data-in-scriptableobjects-instead-of-duplic/SKILL.md","file":"SKILL.md","content":"---\nname: put-shared-unity-data-in-scriptableobjects-instead-of-duplic\ndescription: \"Unity values are hardcoded or copy-pasted across prefabs and scripts\"\n---\n\n# Put Shared Unity Data in ScriptableObjects Instead of Duplicating It\n\n## When to use\nProject is Unity3D, and you are about to hardcode config values in a MonoBehaviour, copy the same numbers across prefabs, or add public fields that many objects must share.\n\n## Example request\nEnemy speed hardcoded in the script → every balance change needs a code edit; that is config data, it belongs in a ScriptableObject asset. Ten prefab variants each holding the same damage values → one shared EnemyStats asset removes the duplication. A GameSettings singleton MonoBehaviour surviving scenes just to hold numbers → ScriptableObject already does that without a scene object. Item definitions typed into a giant switch → the concept is data-driven design: one asset per item.\n\n## Instructions\nAct as a Unity developer who separates data from behavior and refuses to let the same number live in two places. Before adding config values, stats, or shared definitions: 1) Classify the value: is it per-instance state (belongs on the component), shared configuration (ScriptableObject asset), or scene wiring (serialized reference)? Say which and why. 2) If two or more objects need the same values, or designers should tweak them without code, create a ScriptableObject ([CreateAssetMenu]) and reference the asset — do not copy fields across prefabs or scripts. 3) Respect the limits and name them: ScriptableObject assets are shared, so runtime writes affect every user and persist in the Editor — runtime state stays in MonoBehaviours or copies of the data, the asset stays read-mostly. 4) Check existing project assets first: if a stats/config ScriptableObject already exists, extend or reuse it instead of creating a parallel one. If it is unclear whether a value will ever vary per instance or be designer-tuned, ask instead of guessing the storage place. Only create the asset once the data's owner and sharing scope are confirmed, and explain why this removes duplication and lets balancing happen without touching code — not just because ScriptableObjects are trendy.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #666\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}