I built a level builder for a simple match 3 game.
I have a Board class that is sets up of Tiles which is also a class. On each Tile I can place a Block.
The Block is a simple MB class:
public class Block : MonoBehaviour
SerializedField]
[private BlockType blockType;
// more stuff below
}
Each block has a type which is a ScriptableObject class named BlockType.
I use it as Extendable Enum (I saw on YT about using SO’s as extendable Enums and I really liked the idea)
In the editor I’m making a new BlockType asset with a different name for each playable block these are my Enum values and also my dictionary keys.
The basic of BlockType looks like this:
public class BlockType : ScriptableObject
{
public string BundleName;
// more stuff will be added in the future
}
The level builder is for internal use and its purpose is to give a colleague of mine the ability to create level layouts and save it (to file on disk/server etc.) so we can later load it at runtime to the game scene. (not making a scene for each level of course).
I tried a few serialization methods to save the layout but without success. It always boils down to some problems with the List of scriptable objects not serializing/deserializing well. I want to avoid mappings from string to BlockType cause it’s just hard to maintain and defeats the purpose I used SO’s from the beginning.
Also, I would like an opinion on my method of doing stuff. If there is a better way to do it I would love to hear about it.
Cheers.