Scriptable Object

Download

Unity Cheat Sheet: #26

Author Name

Author Name

Author Role

Scriptable Objects are Unity's solution to shared data management. Think of them as reusable data containers that exist as assets in your project. Instead of copy-pasting the same values across multiple scripts, you create one Scriptable Object that everything references.

Core Concepts:

Creation & Storage

  • Create via CreateInstance<T>
  • Save as project assets
  • Load from Resources folder
  • Clone for runtime instances

Data Management

  • Store any serializable data
  • Share between multiple objects
  • Modify in editor or runtime
  • Serialize to JSON if needed

Common Use Cases

  • Game Settings: Store global configurations
  • Item Database: Define game items, weapons, abilities
  • Level Data: Store level configurations
  • Enemy Types: Define different enemy behaviors
  • Audio Banks: Manage sound collections

Event Architecture

  • OnValueChanged events
  • Custom event triggers
  • Runtime value updates
  • Editor value validation

Real World Example:

Instead of copying weapon stats to each enemy:

1. Create WeaponData ScriptableObject

2. Define damage, range, effects

3. Reference same WeaponData in all enemies

4. Change one value, updates everywhere


Why Use Them:

  • Reduces duplicate data
  • Easier to maintain
  • Works in editor and runtime
  • Survives scene changes
  • Perfect for configuration data

Show More