Scriptable Objects

One of the reasons I hate, hate, hate Unity is that all the best documentation is Youtube videos, and I want a book.

Here’s the Brackey’s Scriptable Object tutorial, followed by my transforming the bits I care about into text, for future reference.

Righteo, let’s go:

  • Scriptable Objects exist to be a container for reusable code/data that shouldn’t be a component. Especially universal stuff. (e.g. an enemy type Scriptable Object might be used to create a goblin asset that is assigned to all of your goblins).
    • Bonus awesomeness: because they are assets and not components, changes to them during play mode persist after the play session ends. I should’ve used these suckers to handle, e.g. tweakable character platforming constants (jump force, drag, etc) instead of using fields on a component. Oh well.
  • Derive your class from ScriptableObject instead of MonoBehavior.
  • Decorate your class with [CreateAssetMenu(fileName = "New X", menuName = "X")]. This allows you to make an instance of your asset using the normal Unity Asset Creation pipeline.
  • Et viola.

Did that need a 9-minute video? No. No it did not! (Nothing but props to Brackeys for the knowledge and stamina to produce said video, however!)

Hey, I can use Scriptable Objects to come up with character archetypes for my Piqha RPG, as well as combat moves. How convenient!

One thought on “Scriptable Objects

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s