A useful data point I keep misplacing.

So you want a field in you Inspector that has sub fields. Its sole purpose is to just be a bucket of data, but you have no real need to share it between classes in Unity or have it be universal in any way.

Sounds like a good use for the C# struct, right?

Nah. Unity doesn’t roll that way. You want a plain old class. No inheriting from MonoBehavior nor ScriptableObject. Just decorate that bad boy with [System.Serializable].

Wait, Unity’s default code files don’t include System? I suppose I can see why, as I haven’t noticed ’til now, but years of working with XNA/Monogame led me to not see that coming…

Do consider, however, whether a ScriptableObject might not be right for you.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s