Using scriptable objects or loading from a config file

Hey Hugo…I loved the turn-based straagy course and both of your Kitchen Chaos courses. I’m building an old pen & paper hex based wargame in Unity (like the old Avalon Hill wargames…but not one of those :slight_smile: )
There are thousands of different classes that a unit can be and right now I’m loading in all the unit classes from a csv file. But I’ve been thinking more and more about converting them all to scriptable objects…my only real concern with that is then I’m doing all the editing and hooking up of them in the unity editor versus right now I can control it all with code.

I’m just wondering your thoughts on this… am I overcomplicating things by even thinking about switching to SO? Things just seemed so clean in Kitchen Chaos with your use of them that it feels like the “right” way to do it, but maintaining about 3500 scriptable objects also feels a little unwieldy to me.

Thanks

Scriptable objects are great, but you say you have 3500 units and you already have them in csv format so, why not stick with that?

A scriptable object is a class that is serialised to disk. Your csv is technically the same thing as it is ‘serialised’ data. You can load that data into classes, which is exactly what a scriptable object is.

// scriptable object
public class UnitDataSO : ScriptableObject
{
    [field: SerializeField] public string UnitName { get; private set; }
}

// class for data loaded from csv
public class UnitData
{
    public string UnitName { get; private set; }
}

It’s the same thing. Scriptable objects store the data in a specific ‘asset’ format and loads it again when needed. You have the data in a specific ‘csv’ format and can load it again when needed. If it is easier to use the csv, use that. It will, however, have to ship with the game which may (or may not depending on how you do it) leave it open for anyone to edit.

If you want to go the scriptable object route, you will have to convert all 3500 units into scriptable objects. If you have the knowledge and expertise, you could create a small program that will automatically load the data and create those for you.

But I think sticking to the csv is fine. There is no real difference except for the usability in the editor, which you lose if you aren’t using scriptable objects

If you’ve already done the work to load them from a csv file, you’re far better off sticking to the csv file, unless you are needing to add functionality like linking to specific resources in game like an image sprite. Not saying this as an absolute, of course, just my two cents on the matter.

thanks y’all I appreciate the feedback. I’m going to go ahead and keep it like it is…its working and I’d rather keep making progress on the rest of the game. :slight_smile:

Thanks again

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms