sigtrapgames / SmartData

A designer-friendly, editor-driven Unity3D framework for connecting data and events.
MIT License
271 stars 14 forks source link

Performance question #5

Closed omid3098 closed 6 years ago

omid3098 commented 6 years ago

Hello and thank you for starting this repo. I want to know about reading and writing performance on smart data (generally scriptable objects!) . as their values are being written on disk, is this like reading and writing on textfiles? so should we avoid using them on constantly calling methods like update?

saeedek commented 6 years ago

Checkout this video to learn more about what's under the hood : https://www.youtube.com/watch?v=6vmRwLYWNRo

sigtrapgames commented 6 years ago

ScriptableObjects don't necessarily write to disk all the time - however, I really need to test this in editor. But they do not write to disk at all in builds! See the wiki FAQs for more info.

saeedek commented 6 years ago

I had the same experience with normal usage of SOs, they seem they are written to disk in the Editor,but when you make a build,they don't. The good news is that they are supported by the JsonUtility of unity so you can make a Json out of your SOs, and on save, save the json to disk. and in load, load the json and with the "Overwrite" method of the JsonUtility, populate your SOs again.

sigtrapgames commented 6 years ago

Ok, just done some tests - changing the value at runtime does not write to or read from the disk! The only time it does is if you click File > Save Project.

omid3098 commented 6 years ago

Yes you are right, these changes only will be written on disk inside the Editor and when it comes to builds, their initial value will be use on each game startup. So I guess it look safe to use them as in-memory variables.