From genres
Architects Unity 6 data and decoupling with ScriptableObjects: config/data assets, shared runtime variables, event channels, and runtime sets/registries. Use when designing data-driven systems or replacing singletons/managers.
How this skill is triggered — by the user, by Claude, or both
Slash command
/genres:unity-scriptableobjectsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use `ScriptableObject` assets to store shared data and decouple systems in Unity 6 —
Use ScriptableObject assets to store shared data and decouple systems in Unity 6 —
configuration, event channels, and registries that live as project assets instead of being
hard-wired into scenes or singletons. Targets Unity 6 (6000.0 LTS).
static/singleton manager.*.asset data files backed by : ScriptableObject classes.When not to use: per-instance runtime state that differs per GameObject (that belongs on
a MonoBehaviour) — a ScriptableObject asset is shared by everyone who references it. Saving
player progress to disk → save-systems. Plain DTOs that never need to be an asset can just be
[System.Serializable] classes.
ScriptableObject and tag it with [CreateAssetMenu] so
designers can create instances from the Assets menu..asset instances in the Project window; each is a shared, named
piece of data referenced by [SerializeField] fields.OnEnable if the asset is mutated during play, because edits
made in the Editor at runtime persist on the asset (a frequent source of "my values
changed after I played").using UnityEngine;
[CreateAssetMenu(fileName = "WeaponData", menuName = "Game/Weapon Data", order = 0)]
public class WeaponData : ScriptableObject
{
public string displayName = "Pistol";
public int damage = 10;
public float fireRate = 0.25f;
public GameObject projectilePrefab;
}
public class Weapon : MonoBehaviour
{
[SerializeField] private WeaponData data; // assign the shared asset in the Inspector
private void Fire() => Debug.Log($"{data.displayName} for {data.damage}");
}
[CreateAssetMenu(menuName = "Game/Float Variable")]
public class FloatVariable : ScriptableObject
{
[SerializeField] private float initialValue;
[System.NonSerialized] public float runtimeValue; // not saved to the asset
private void OnEnable() => runtimeValue = initialValue; // reset each play session
}
// Player writes playerHealth.runtimeValue; the HUD reads it — neither references the other.
// For transient SO data you build in code (e.g. a generated config).
var temp = ScriptableObject.CreateInstance<WeaponData>();
temp.damage = 25;
// ...use temp... Destroy(temp); // clean up runtime-created instances
[NonSerialized] fields
reset in OnEnable, or it will surprise you. (In a build, asset edits do not persist
across launches.)OnEnable/OnDisable/OnDestroy but no
Update. Don't expect per-frame callbacks.save-systems instead.CreateInstance objects — runtime-created instances are not garbage-collected
like plain C# objects; Destroy them when done.GameEvent SO + listeners, type-safe payloads) and
runtime sets/registries (a shared list of active enemies), read
references/event-channels.md./Manual/class-ScriptableObject.html) and
ScriptReference/ScriptableObject, ScriptReference/CreateAssetMenuAttribute.unity-csharp-scripting — the MonoBehaviours that consume these assets.save-systems — persisting state to disk (what SOs are not for).card-game / rpg / survival-crafting — genres that lean on SO-driven data.npx claudepluginhub gamedev-skills/awesome-gamedev-agent-skills --plugin workflowsUnity data-driven design architecture. ScriptableObject config hierarchies, JSON data pipelines, designer handoff workflows, data versioning and migration, Inspector attributes for self-documenting configs. DECISION format: WHEN/DECISION/SCAFFOLD/GOTCHA. Based on Unity 6.3 LTS.
Writes Unity 6 C# gameplay scripts using MonoBehaviour lifecycle, component access, coroutines, and Inspector serialization. Use when creating or editing .cs scripts in a Unity project.
Guides Unity development across platforms with patterns for MonoBehaviours, DOTS/ECS, ScriptableObjects, prefabs, and performance optimization. Useful when building or debugging Unity games.