Scriptable Objects

Last modified by Maarten Struijk Wilbrink on 2021/11/01 14:07

Getting Started

Scriptable Objects are fantastic tools, in the right circumstances. They are little assets that live inside the Projects folder. This allows you to easily reference them from one or multiple places, and is a great way to make sure that data or code is only expressed once in your project. 

Tips and Tricks

A quirk of SOs is that you can change the data in them during Playmode, which then persist. This can be great when trying to figure out the correct setting. 

Caveats

  1. In a Build of your Project, changes to data in your SOs don’t normally persist across Scene changes. If you want to do this, you should either work with Additive scenes (recommended approach), or store the affected SOs in a List which is on a DoNotDestroyOnLoad GameObject. 
  2. Custom Events with Unity Event extensions do not normally pass their extension data across Scene changes. Again, using Additive scenes may help here. 
  3. When using the SO Events approach mentioned below, stay mindful of the number of Events you’re creating. This can quickly become overwhelming. 

SO Basics
SO Variables && Events: Ryan Hipple Unity 2017 talk

Tags:
   
solo
XWiki 14.10.13
contact@xwiki.com