- Home /
Recommendations for Data Format in C# Project (JSON, XML, Lua, etc)
I've been working on a project for a while, but it has reached a point where copious amounts of data will be needed. After spending a few days looking around online without any solid comparisons of the varying formats in terms of use, performance, etc., I thought I would drop an ask here to see what some of the more experienced developers have to say on the topic.
I'm looking for recommendations based on your experiences with any form of data storage/access with regard to ease of implementation, parsing performance, modification/creation of data, platform compatibility, or anything else you feel is relevant.
A couple key points to keep in mind: - The project will be mostly offline, though updating will happen in some form - The data needs to be accessed and potentially modified at runtime (or upon exit)
I know it's a rather general and slightly opinion-based question, but I think the relevance of performance and platform compatibility legitimizes it. I couldn't find any similar questions here using a few keyword searches, and anything I found in a web search was either minimal or outdated, and definitely wasn't targeted to Unity itself (which I assume would make a difference anyway).
Any viable input is appreciated
Answer by UnityCoach · Apr 30, 2017 at 10:14 PM
I would suggest to use ScriptableObject along with Json serialisation.
ScriptableObject allows you to store custom data when in the Editor and use it at runtime. You can even include it in AssetBundle if you need to support DLC.
Now, AFAIK, you can save it at runtime, this is where Json serialisation comes into play.
You can add all the Json markups to you ScriptableObject class, which allows you to create new instances at runtime, and save them to disk.
Btw, I'm about to release a training chapter on $$anonymous$$odel-View-Controller pattern with Unity and I'm touching on ScriptableObject. Subscribe to my newsletter to receive a free access.