Create/Store a table of information for lookup by multiple scripts (C# for iOS)

So I’ve done a lot of reading around (don’t come from a coding background) and definitely still need help!

I’m making a companion for a card-game. I’m firstly working on the character cards which are grouped into different kingdoms.

My big question is really how, and where, to store all the information about the kingdoms and the cards so that it can be accessible globally (many scripts need access to this information).

I’ve started learning about classes and arrays… I understand little about what exactly happens when you make something public and void and whether that’s necessary here… I’ve heard about hashtables… and other mysterious ‘.net files’… but I’m not sure really where to start.

This is what I want to store… and some examples of how the information needs to be accessed:

Each kingdom needs to store the names (string) of each of it’s characters… it needs to store references to each characters image files… references to their thumbnail image files… references to their sound files.

2401830--163895--upload_2015-11-30_21-28-37.png

• Each folder (kingdom) menu item needs to be able to know/access a count of the number of characters within any given kingdom (in multiple scripts to do with positioning and repositioning).
• Each instantiation of the thumbnail prefab needs to know which card it has been associated with and access the corresponding thumbnail image file

Then characters need to be able to be added to the kingdoms… so whatever reference we create must be editable. (I’m learning and doing everything in C# currently).

Thanks in advance.

google “unity scriptableobject” (note the lack of space in the second word)

1 Like

ScriptableObject is a good place to start. For something like this you might also want to investigate using an external database that you can read into Unity. Unity is not the greatest for mass editing of data.

Thanks guys BUT… just watched a long podcast of a live scripting session on Scriptable Objects… and don’t feel much closer to the answer.

It seems in there were all about how scriptable objects can be useful in the unity editor… not in my runtime project.
Maybe scriptable objects are what I’m looking for but I still need help.

Would I use a script attached to, say the camera, to on Start () Initiate my entire library of scriptable objects with their different data sets? … Or rather do I do that, run it so that the assets are created… then now that I have say an asset per character (seems like a lot!) do I delete the script…

and then still if I had a scriptable object for each character… or even for each kingdom… I don’t know how to load/access the data stored in them in other scripts as I need to as mentioned above. Any help?

Would it be less complicated to have lots of arrays/lists of data in a script attached to… again lets say the camera… and just somehow have a reference to that script in every other script that needs access to the data… and access the data that way? Do I need to make the data in the ‘storage’ script public for it to be accessible by other scripts?

Again, appreciate the tips, I’m always learning even when I find out ways not to do it :stuck_out_tongue: