Scriptable Objects vs Prefabs for card game

Hello everyone,

In my game, each card has its own unique features, and each card can only be used once. I’m thinking of using prefabs, with each prefab having a different class inherited from “Card → MonoBehaviour”.

I also learned about the capabilities of scriptable objects, but is it possible to attach different kinds of effects to them. For example in my game there is a card that reveals all the cards of the opponent, or takes the opponent’s card. Another reason to pay attention to the Scriptable object is that not all the cards present in the game will be used in the match.

As an example of the map structure, I have attached a diagram

I apologize for possible errors in the text, since I use a translator

The solution may involve MonoBehaviours that accept a ScriptableObject to configure them.

MonoBehaviours are necessary to go in the scene (eg, make Prefabs)

ScriptableObjects are data containers.

Look at some card game tutorials. No sense in someone retyping it all here.

Of course many different approaches are possible, but using ScriptableObjects for a card game can work very well.

ScriptableObjects are not just good for holding data, you can basically do anything with them that you want, including creating functions or events, or even using a scriptable object as an effect executor, that you can plug in somewhere.

There is a great talk about it by Unity, if you haven’t seen it already.

This should give you a great starting point for choosing the right code structure for your game

If I were to tackle a card game (and I 100% want to at some point), I would design my cards entirely as scriptable objects, and have the in-game cards generated at runtime. Maybe some editor tooling to generate the prefabs if there was performance issues with runtime generation.

Though using scriptable objects would 100% require use of SerializeReference to serialise a polymorphic list of abilities, to keep things flexible and scaleable, which means custom inspector work or using tools like Odin Inspector.

Mind you a card game is going to require tons of custom inspector and editor work anyway. I would probably design some kind of elaborate card-designer editor window myself. Would honestly be something akin to UI Toolkit UI builder.