Enter The Mansion Card Editor

It’s been a little while since I’ve been able to work on Enter the Mansion, but I got back on it this week and finished up my rudimentary card editor. Previously, I’d been looking at scriptable assets and how to use them as a way for designers to create different ‘cards’ that could be displayed in game. This week I focused on how to make this card setup a little easier to use.

I’d initially hoped to have the TextArea boxes in the editor UI be the same size as the area in the game UI, so users wouldn’t have to check their word/character counts in game. Unfortunately I also wanted spell check, and the spell check package I used only game with extendable TextAreas that are a fixed size to start off with. Ultimately I preferred having spellcheck over the counts thing, as all content should be tested in game anyway!

The spell check feels a little clunky, as it is a separate window and does not offer suggestions, but its damn sight better than nothing and far more complex than anything I’m currently equipped to make myself.

In addition to the spellcheck, I added a slot in the card asset for an image that is then displayed in the UI alongside the text. Keeping these together is important, so that when I’m writing the room’s description, I can ensure that the text and the image match.

In addition to the window I added a unique, generated ID to each card. This is for debugging and tracking purposes, especially as content changes. Initially I wanted to create an ID when the asset was created and have it static, but Unity wouldn’t let me look up the asset database in a constructor, so I did it when the card loads instead. This actually turned out to be a good thing, as it meant that if I delete a card the others update accordingly.

    //assign ID to cards when they are loaded
    void OnEnable() { 
        string[] assetNames = AssetDatabase.FindAssets("", new[] { "Assets/Cards" });

        foreach (string asset in assetNames) {
            string assetName = AssetDatabase.GUIDToAssetPath(asset);
            string[] assetNameSplit = assetName.Split('/');
            assetName = assetNameSplit[assetNameSplit.Length - 1];
            assetName = assetName.Split('.')[0];

            if ((assetName + " ") == this.ToString().Split('(')[0]) {
                this.ID = System.Array.IndexOf(assetNames, asset).ToString();

The last thing I did on this was add a button that moves through each of the cards, replacing the former random card on start logic I had in there before. This is a lot easier to test until I decide how I actually want to deliver my cards!

void setCard()
        if (card != null)
            int current_index = cards.IndexOf(card);
            card = cards[current_index + 1];
            card = cards[0];
    catch (System.ArgumentOutOfRangeException e)
        card = cards[0];

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