Best way to create and use tile assets

I am developing a 2D number puzzle which needs numbers from 1 to 30. I am unable to decide on the better of the 2 following approaches:

A) create graphic asset for each number and instantiate a few of each in a pool and enable/disable as needed

B) Create blank tiles and use GUIText gameobjects to dynamically paint the number over the tiles. This has the complication of managing GUIText coordinates tied to the tiles but does it offer any benefits over the other method?

Would appreciate any advice…

I would definitely go with option A - for performance reasons and for the reason you pointed out.

If you make PNGs of numbers from 0-9, and make a prefab with 2 sprites next to each other, it’s pretty easy to make a script that will allow this prefab to display any number from 0-99


I had a spare script handy so you can have it… to give food for thought if nothing else :slight_smile: This can be used to make a 3 digit, center aligned counter if you just drag the 3 SpriteRenderers into the _Rederers array and the 10 PNGs in order to the _Numbers array. You probably have to adjust OFFSET to be much smaller (I was using pixels to units == 1).

using UnityEngine;
using System.Collections;

public class Counter : MonoBehaviour
	const float OFFSET = 40f;

	public SpriteRenderer[] _Rederers;
	public Sprite[] _Numbers;
	public void set(int numberToshow)
		if (numberToshow < 0 || numberToshow > 999) return;

		_Rederers[0].sprite = _Numbers[(numberToshow % 10)];
		_Rederers[1].sprite = _Numbers[(numberToshow % 100) / 10];
		_Rederers[2].sprite = _Numbers[(numberToshow % 1000) / 100];
		if (numberToshow > 99)
			_Rederers[0].gameObject.transform.localPosition = new Vector3(OFFSET,0,0);
			_Rederers[1].gameObject.transform.localPosition = new Vector3(0,0,0);
			_Rederers[2].gameObject.transform.localPosition = new Vector3(-OFFSET,0,0);
		else if (numberToshow > 9)
			_Rederers[0].gameObject.transform.localPosition = new Vector3(OFFSET/2f,0,0);
			_Rederers[1].gameObject.transform.localPosition = new Vector3(-OFFSET/2f,0,0);
			_Rederers[0].gameObject.transform.localPosition = new Vector3(0,0,0);
		_Rederers[1].enabled = numberToshow > 9;
		_Rederers[2].enabled = numberToshow > 99;