reuse texture between quad
I want to spawn multiple blocks, each representing a letter. There will be more than one copy of an alphabet.
I have a big texture which contains all the letters in it. I use a prefab to Instance
all the Blocks(quads) during Awake()
. At runtime, I'd like to assign a texture to these quads (identifying the letter). My code looks like this:
void Update () {
// if there is no active block, spawn it
if (activeBlock == null) {
this.getNextBlock (ref this.activeBlock);
}
protected Block getNextBlock(ref Block block){
block = this.deQueueBlock ();
char letter = LetterMgr.Instance.getNextLetter();
// based on the letter, index into texture
// and assign the texture + indices to this block ?
}
How can I reuse this one big texture and index into each letter amidst all these blocks (quads)
? I will be rendering this on a mobile, so will need to squeeze all the performance I can. Details:
256 x 256 per letter
8 columns x 4 rows
Total Texture Size: 2048 x 2048
Total number of blocks: ~100
PS: Each of the letters will be moving and will eventually come to rest. So I will have some (around 6-7) actively moving blocks and others will be stationary.