Is ScriptableObject suitable for fast data write/access?
I am about to get into the world of Sciptable Objects. I would like to use scriptable objects for several things in my project. First of all I have checked the official learn about ScriptableObjects video from Unity. I know that I can mainly use it to store data, and mainly I am going to use it to store settings in my project, however there is a great deal of data coming in live from a source through the network. I would like to use that data live too. So basically imagine a stream of position datas etc. coming in, and updating. I would like to access that data as it is coming in. I know that I could just use a standard class object for this, but I was thinking it might just be cleaner to use one Scriptable Object and access the settings and the live data form that.
My question is if ScriptableObject is slower to access than a normal class in Unity. or is the difference totally not significant? (I was wondering because I heard that ScriptableObjects are written to storage, just as System.Serializable sctructs and classes, does that mean Scriptable Objects would behave with the same reaction time as the System.Serializable classes?)
Answer by kornel-l-varga · Jun 15, 2017 at 11:38 AM
I have made a small Benchmark method to test the reading and writing. I have used a random string that I generate for each sample. The string is 100000 character long. I have used both DateTime.Now.Ticks & DateTime.Now.Milliseconds. The time in milliseconds before and after the writing in both static class and ScriptObject cases are equal. I was wondering if there is a way to see more accurate measurement (I have read some forums about it, and I saw that a native plugin would be needed). Any ideas?