Map xls to Scriptable Objects

Greetings, I’ll explain my problem:

I’m developing a board game that uses cards with text, as monopoly does for instance. Each card is created as a Scriptable Object so that I can add the text manually through the Unity editor and create the card object. The thing is I have a xls file with text for different cards in each row, having hundreds of lines which would take plenty of time to introduce by hand.

Is there a way in which I could automatically create a SO from each row of the xls? Maybe the SO approach isn’t very efficient here considering the format the data is stored?

Thanks in advance.

You write a function that does that, and call that function!

If this is a one-off thing, I’d write a [MenuItem] command that parses the xls file and generates all of the corresponding ScriptableObjects. If you’re doing this several times, I’d make an editor window that allows you to specify the path to the xls file and other options you want to have.

Please ask if there’s any part of the process you need help with. Your post is a bit vague about what you’re not managing to do. Is it parsing the file, creating the SOs, storing the SOs, or what?

In case it’s creating the SO’s, you can call ScriptableObject.CreateInstance() to create it, set all the data you want on it from the xls, and then use AssetDatabase.CreateAsset to store that SO as a file in your project.

1 Like

Yes sorry I forgot to specify. The problem was that, how to create the SO from a C# script, I’m in begginer using Unity at the moment. Thanks for the reply, I’ll try your advice.