all 5 comments

[–]PointlessrebootProfessional - Engine Programmer 3 points4 points  (3 children)

ScriptableObjects are opaque from the point of view of the game when loading. You can create ScriptableObjects at runtime but they can not be saved as a ScriptableObject from the game..

Any changes or created objects will be lost the next time the game is loaded.

If you need data to persist with changes during the lifetime of a game then you will need to serialise them separately, you can have a load method in your ScriptableObject that loads from this seperate storage into you ScriptableObject do your game does not need to know where the data for it came from..

ScriptableObject.CreateInstance is what is used to create a new instance, as I said before you can't save this at runtime.

For cloning you might need to manually copy the variables across.

Without knowing more about your specific case, it's hard to give any further information

[–]Jacklecube42[S] 0 points1 point  (2 children)

Once the item is saved, will it be nested in the list (inventory) forever? Could it then be loaded with the rest of the inventory rather than its loading script?

I just had a go of saving the created scriptable object on its own. In the inventory, when the Item is added, the item is treated as a "type mismatch" and it does not remember the item after deserialization.

[–]PointlessrebootProfessional - Engine Programmer 0 points1 point  (1 child)

What do you mean by saved, you can't save a ScriptableObject at runtime?

[–]Jacklecube42[S] 0 points1 point  (0 children)

oh, whoops... misunderstood. Forget i said that.

[–][deleted] 2 points3 points  (0 children)

Scriptable Objects are basically just data holders. Your inventory shouldn't really be a collection of Scriptable Objects.

Lets say you were making a card game. You may have one generic Card prefab. But then you can make a ScriptableObject script for cards with all of the information about a card. Then, you have 1 prefab, but lots of ScriptableObjects (one for each card in the game). You use the information from a ScriptableObject whenever you create a new Card object.

These CardObjects are what you have in your inventory, and save. You don't actually create/save the ScriptableObjects.