Unity's ScriptableObjects hold shared data in one place.

The problem
The same numbers, fifty times.
public class Weapon : MonoBehaviour{ public int damage = 10; public float fireRate = 0.2f;}// on 50 prefabs
Rebalance the pistol and you're editing every prefab that has one, hoping you didn't miss any.
The fix
Data lives in an asset.
A ScriptableObject is an asset file that holds data. Many objects can point at the same one.
50 prefabs→1 Pistol asset
The fix in code
Define it, then reference it.
[CreateAssetMenu]public class WeaponData : ScriptableObject{ public int damage = 10; public float fireRate = 0.2f;} public class Weapon : MonoBehaviour{ [SerializeField] WeaponData data;}
Create a Pistol asset from the menu, drag it into every weapon. Change it once, every pistol updates.
Watch out
It's shared, so don't store state.
Every weapon reads the same asset. Changing it at runtime changes it for all of them.
- Base stats
- in the asset ✓
- Current ammo
- on the component
- Edits in Play mode
- stick in the editor
The rule
Shared data in an asset. State on the object.
- Base stats
- ScriptableObject
- Per-object state
- the component
- Rebalance
- edit one asset