Scriptable Object Factory

Scriptable Object Factory - Article - Tal Lior

ScriptableObjectFactory Unity Package Download Link - Dropbox

ScriptableObjectFactory Link - Box.com

The ScriptableObject Factory provides an Editor interface that makes it easy to create scriptableObject instances in your project. Otherwise, additional custom code must be written to add an option to the menu to allow creation of a scriptable object interface.

Any class that inherits from ScriptableObject will now show up as an option in the Project Assets Menu:

The image below shows that the Scriptable Object Factory places a new folder: Editor, with 2 scripts: ScriptableObjectFactory.cs, ScriptableObjectWindow.cs.

You can delete files: First.cs, Second.cs that are imported as examples with the scriptable object factory.

  • Add a public instance of the Scriptable Object to a custom script that will be attached to a gameObject in a scene. In our case this is the DialogManager.cs script.

    public class DialogManager : MonoBehaviour {
    
       public ConversationList convList; //attach scriptable object in Inspector
    
       //more class definition code below
  • Use inspector to select a ConversationList scriptableObject from your project's assets, to populate the convList variable defined above.

Scriptable Objects - Unity Manual, Scripting API

ScriptableObject is a class that allows you to store persistent data independent from script instances. A class you can derive from if you want to create objects that don't need to be attached to game objects. This is most useful for assets which are only meant to store data.

Last updated