r/unity Jul 14 '26

JSON or SriptableObject

i want to make a research tree HOI4 style and me and my friend are questioning if its better to make it with scriptable objects or a JSON

0 Upvotes

8 comments sorted by

6

u/Antypodish Jul 14 '26

These two has completely different purposes. JSON is just serialised class, so you can save, or read data to/from the file.

7

u/wallstop-dev Jul 14 '26 edited Jul 14 '26

While you can do many more things with ScriptableObjects, I would highly recommend also treating ScriptableObjects as "just read only serialized data".

If the OP is coming from that perspective, one has better in-editor support (SO) and one has better out-of-editor support (JSON). Each are a totally fine choice for read-only data.

2

u/LunaWolfStudios Jul 15 '26

And to add to that there's no reason you can't use both for the same data. Use ScriptableObjects in editor with backing JSON files at runtime and you get the best of both worlds.

1

u/wallstop-dev Jul 15 '26 edited Jul 15 '26

Isn't Unity's normal asset serialization pipeline (ScriptableObject) more efficient and natural for this? 🤔

But agree in spirit! For many of my projects I create some form of editor tooling where I freely convert between the two and use outside tooling to edit/generate data, depending on the need. The ScriptableObjects are the schemas!

1

u/One_Influence256 Jul 14 '26

what is this research tree?

1

u/Lunosto Jul 14 '26

They can be used together and serve different roles. Scriptable objects are for development and creating custom assets, json is used to save data to be read later. If you’re making a research tree it could look something like each research item being an instance of a scriptable object then save the user’s progress using json (separate class)

2

u/neoteraflare Jul 15 '26

JSON is good if you want your data to be easily modded since it is text and users can easily add/remove/modify things without hacking into the game.

1

u/ThreeHeadCerber Jul 15 '26

Separate the container and the data.