- Home /
ScriptableObjects in a List all become nulls on Play
This has been driving my crazy! This looks like a pretty simple, straight-forward setup, doesn't it? I can add and edit instances of TileMapping inside the inspector for my AreaGenerator, editing the colors and object fields without any trouble. However, as soon as I press the Play button every instance in that list immediately becomes None/null and remains so when I exit play mode. The size of the list does not change, it just becomes a list of nulls.
Why would this happen? I've tried many variations. I've tried [Serializeable] instead of a ScriptableObject, but then I can't keep instances of this for reuse as assets. This is driving me absolutely batty because it should be the easiest thing in the world. I'm not doing something unusual or special or complicated here.
What am I missing?
public class TileMapping : ScriptableObject {
public Color color;
public GameObject prefab;
}
public class AreaGenerator : MonoBehaviour {
public GameObject pfTile;
public Texture2D map;
public List<TileMapping> tileMappings;
}
Your answer
Follow this Question
Related Questions
Add lines to a script from another script 0 Answers
Serializing a ScriptableObject without creating an asset for it? 2 Answers
pass child class to ScriptableObject.CreateInstance<> ? 1 Answer
Custom assets give Missing (Mono Script) 0 Answers
ScriptableObject stored in MonoBehaviour lost on quit 1 Answer