Scriptable object woes.

Hi!,

I have an scriptableobject class called world. This scriptable object will keep data about my different worlds. The problem is that I have now 5 scriptable objects assets on disk created from world (I create the asset from world and changed the name to the needed world). I called them world1 … world5. How can I load world1 scriptable object? Perhaps I’m missing something here because the method signature for the ScriptableObject only accepts a class type.

Can’t I have different instances from the same scriptable object serialized and load them when needed?

You can access them like any other asset. Just store a link to your “world assets” in another script on a object in the scene or place them in the resources folder and use the Load function. The usual way is to reference them somewhere.

For example if your ScriptableObject class is called “MyWorldObject”, you could do this in a script attached to an object in the scene:

//C#
public MyWorldObject[] worlds;

// UnityScript (Unitys Javascript)
var worlds : MyWorldObjects[];

Just drag your world assets to the array variable to add the references. At runtime this script can access all your scriptable objects by using those stored references.

When you don’t “use” (reference) an asset, Unity won’t even include it in your build.

ScriptableObject.CreateInstance