I have made a scriptable object BlockData1 i then make the different block data with the creation tab. When i reset my game, the BlockData i made resets or losing it’s script. The point is that it is not saving the data that i put in it. How do i fix this
Scriptable objects are only saved when you’re in edit mode and you don’t instantiate them, any other time (at least as far as my experiences go) it’s not permanent. I personally used playerprefs to store the most important portions to save and used that.
Indeed i only create my blockdata in edit mode from the create menu and my custom tab gained from CreateAssetMenu.
The problem is, when i reset the game my blockdata. as seen in the picture “What it looks like after resetting my game”. the blockdata object copper says it is missing a script or the values was not saved. How do i make sure that unity saves these values even though i restart my game?
Before restarting the same instance of the copper would have fields as block name and sell price and what not.
My initial idea was to have a scriptableobject class blockData and from that create Gold , Copper , … and then the information would be saved in those like showen on the “What it looks like after resetting my game”
In the editor, all changes to ScriptableObjects during edit and play mode persist. If you need to modify the data but want that data to be reset when you exit play mode, create a copy of the ScriptableObject in Awake/Start and use that instead.
So if you make a brand new Blockdata1 ScriptableObject via the Create menu, set the sell price in the inspector, then close and re-open Unity… it’s just gone?
Yeah exactly and i have used ScriptableObjects before where it did not happen. which makes the whole situation very weird. It looks like it is missing the script or something like that. Ref to the picture “What it looks like after resetting my game”
Did you solve that? I have the same problem and it seems that once I changed a property of my scriptableobject once it can’t be changed back which is really weird. And if I stop the game, the change persist but I can’t change it back in play mode.
Not all data types can be serialized, I don’t have the correct answer but the use of dictionary or texture may be what is causing the conflict, try changing the dictionary for another type of structure.