Unable to assign ScriptableObject in inspector
I am having trouble assigning ScriptableObjects in the inspector.
For example, I have this class:
using UnityEngine;
public class Buff : ScriptableObject {
public string buffName;
}
In one of the classes derived from monosecurity, I have a member like this:
public Buff testBuff;
In the inspector I can see the following, but I cannot drag the + drop script 'Buff' into this member
It works to drag the + drop Buff as a new script, but I cannot add it to the "Test Buff".
What I tried instead of dropping + dropping is to just instantiate Buff like so:
public Buff testBuff = new Buff();
It worked: However, I believe drag + drop should work as well, plus the above gives a warning:
Buff must be instantiated using the ScriptableObject.CreateInstance method instead of new Buff.
UnityEngine.ScriptableObject:.ctor()
Buff:.ctor()
...
I am using Unity "5.0.2f1 Personal" which is the latest version.
source to share
You need to create an asset file that uses your Scriptable Object as you type it. This can only be done with a script editor. There is a generic wiki .
Essentially you just create a menu item for each type of Scriptable Object you use, use the menu item to create assets of those types, and then modify the assets with the values ββyou want. It is important to remember that SCOs must be used as templates, if you modify SCO either in the editor or with code, these changes will take effect instantly for all GameObjects and components that reference SCO.
source to share