Does loading a ScriptableObject on runtime and modifying it affect the ScriptableObject in file?
I have a ScriptableObject
loaded on runtime using Resources.Load()
. I use this ScriptableObject
to store data which I use to initialize my game sessions. However, sometimes, I may need to modify the initialization data stored in the ScriptableObject
. Is this safe to do?
Answer by arielsan · Aug 10, 2016 at 07:52 PM
@brain56 The stored asset is not modified, so if you restart your app the ScriptableObject will have the original value, but the data in memory is modified as long as I know so if you modify the reference after the Resource.Load() and then you call Resource.Load() in another part of your game, you will probably have the modified version.
I believe you can do a super quick test for that.
Warning: if you are in editor, the scriptable object in Unity memory is modified, so if you select the scriptable object asset you may see the modified version in Inspector but it is not going to be saved, if you restart unity you will have the previous version.
Your answer
Follow this Question
Related Questions
Weird Issue: Textures become transparent when running from the editor in an android platform 0 Answers
Loading a new sprite into an image array 0 Answers
Unity hub, learn resources 0 Answers
Can some give me a script to make ghost walk around? 0 Answers
Setting an asset to an instance of a class in a script 1 Answer