I have a problem and the following message appears:
“RemoteSO must be instantiated using the ScriptableObject.CreateInstance method instead of new RemoteSO”
Basically I have a Scriptable Object that contains other Scriptable Objects. On the other hand, I have a JSON file with the same structure, which I deserialize in order to fill the RemoteSO data using the following code:
RemoteSO auxRemote = ScriptableObject.CreateInstance(“RemoteSO”) as RemoteSO; auxRemote = JsonConvert.DeserializeObject(jsonRemote);
Everything works fine, but I get Warning messages. What I can do?
I know, but actually I have a complex SO with other SO inside. The error message is from this line JsonConvert.DeserializeObject(jsonRemote) because i suppose when you Deserialize an object, a new Object was created. Also, it works perfectly, but i don’t know why the error message is showing.
Doesn’t change what I said. You can’t and shouldn’t serialise out entire Unity objects, it’s not supported. What might work in one situation will likely fail in other situations.
Represent your save-able data with plain classes/structs, represent your runtime data with scriptable objects. Just sounds like a case where you need some serialisable surrogate classes.
Well. I follow what “iron_asaf” said on this post:
And finally, I created a sister/clon class for each of my scriptable objects.
Then just deserialize the json with the sister classes and assign to my SO classes.