Reputation: 6278
Newly added field in ScriptableObject class not being put into assets of its type. Is this something todo with how Scriptable Objects work? Is there a way to update a scriptable object asset without losing existing info in already populated fields?
My ScriptableObject class has a bunch of strings for animation:
public class SO_AnimStringNames : ScriptableObject {
public string FirstAnim;
public string SecondAnim;
public string ThirdAnim;
}
I've created a ScriptableObject asset via this class, and added names to the strings, and used it as data within another object type, that uses those strings.
Just now, added a fourth string to the ScriptableObject class, so now it looks like this:
public class SO_AnimStringNames : ScriptableObject {
public string FirstAnim;
public string SecondAnim;
public string ThirdAnim;
public string FourthAnim; // newly added field
}
but it's not seen/updated within the ScriptableObject asset, and there's no obvious way to update this asset.
Is this a limitation of ScriptableObjects, or is something else wrong?
Upvotes: 1
Views: 2575
Reputation: 74
I'm a bit confused with your issue here, so...
Option 1:
I just tried what you did, but I added the CreateAssetMenu
attribute on top of your class, someone mentioned you probably didn't share all of your code but in theory this is how it should be looking:
[CreateAssetMenu(fileName ="NewAnimStringNames",menuName ="Animation Names")]
public class SO_AnimStringNames : ScriptableObject
{
// made an instance with these three first
public string FirstAnim;
public string SecondAnim;
public string ThirdAnim;
// then added the fourth variable, the instance I created previously updates correctly
//and keeps the values I set on the other three
public string FourthAnim;
}
Is that how your ScriptableObject
actually looks and you're creating them from Assets/Create menu or with right click on your assets plus create menu?
Option 2:
They also mentioned that maybe you have another issue that is not allowing Unity to recompile leading to your ScriptableObject
updating itself with the new field? Please check the console for any other issues.
Upvotes: 2