Generate a connected list consisting of scriptable objects.

I would like to create a database consisting of connected nodes. Each node will contain an element (a character) and a list of other nodes that it’s connected to.

I do not want to generate this list everytime the game is played, I want it stored as part of the game’s files. Also the database will need to be quite large so if I were to use a scriptable object for each node then I would want to somehow generate these nodes in code rather than make each one individually.

How do you create and modify scriptable objects as assets as opposed to creating instances on every play?

Would there be a better way of doing this such as storing an array in a text file?

You cannot create and save a SO at runtime, only create instances of pre-existent SOs. Hence you have to either create them manually before building the project, or save the nodes (using some sort of IDs because you can’t save references) using PlayerPrefs or JSON serialization.

You could also try to use one single SO that contains your entire “database”, then simply use it to load the data from it at runtime, but you will have to fill it with data manually.

You can also save and load your database in a text file included in the project, like this: