Geek Culture
Published in

Geek Culture

What Are Scriptable Objects In Unity?

Scriptable Objects are a great feature of Unity. They allow the storing of data independent from GameObjects, MonoBehaviours, Scenes, and any sort of save file.

Image from Boundfox Studios — Youtube

A Scriptable Object is a data container that you can use to save large amounts of data, independent of class instances. — Unity Documentation

The main use cases for Scriptable Objects are:

  • Saving and storing data during an Editor session.
  • Saving data as an Asset in your Project to use at run time.
Example Scriptable Object

Coding a Scriptable Object:

A Scriptable Object is written similar to a normal monobehaviour. However, it must inherit from the UnityEngine.ScriptableObject base class.

You may choose to add the CreateAssetMenu Attribute too. It makes creating SO instances easier, by adding an entry into the Create menu (Right-Click in Project panel).

Right-click/Create/The string specified for “menuName” in the Attribute
The new Scriptable Object is created in the Project files, and you can set the variables by selecting it

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

153 Followers

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.