Skip to content
Adam Graham edited this page May 12, 2025 · 18 revisions

Links

FAQs


Is the source project free to use?

Yes, you are free to use the project for any purpose. However, keep in mind that copyright and/or trademark laws can still apply to the original material since many of the games in my tutorials were not originally authored by me. I open source my own code for the community to learn from, but the project is intended for educational purposes only.


Can you use images instead of text on the tiles?

Yes, you can! First, replace the Text component on your tile prefab with an Image component. In your TileState class, store a reference to the sprite you want to display for the tile state:

[CreateAssetMenu(menuName = "Tile State")]
public class TileState : ScriptableObject
{
    public Color backgroundColor;
    public Sprite sprite;
    public int number;
}

Be sure to assign the sprite for each tile state asset in the Unity editor.

In the Tile class, you'll need to replace the reference to the Text component with a reference to the Image component. However, there's a slight problem here. In the Awake function we are assigning a reference to the background image using GetComponent. If we replace the Text component with another Image component, there won't be a reliable way to distinguish which Image component is retrieved since there will be more than one. Instead, we can remove the Awake function entirely and add the [SerializeField] attribute to each of our references.

public class Tile : MonoBehaviour
{
    //...

    [SerializeField] private Image background;
    [SerializeField] private Image icon;

    //...
}

This allows us to manually assign the correct reference to each Image component in the Unity editor. Make sure to go back into the Tile prefab and assign these references or you will get some errors when running the game.

Finally, in the Tile class we just need to update the SetState function to assign the sprite instead of set the text. Replace this line of code:

text.text = number.ToString();

with this line of code:

icon.sprite = state.sprite;

Clone this wiki locally