Drawing Multiple Textures to the GUI during runtime

I’m helping code something similar to a scrabble game and have been having trouble with the GUI. What I want to happen is when I collect a letter in the game it will show up on the GUI and if I collect subsequent letters they will also show up on the GUI in a specified place. I already know the place I want them to be but I’m wondering how I can add textures to the GUI during runtime. So far I have the basic GUI being drawn with box’s.

void OnGUI(){
        if(scrabbleTile != null)
            GUI.DrawTexture(new Rect((Screen.width - 600) / 2, Screen.height - 100, 50, 50), scrabbleTile);
        
        
        GUI.Box(new Rect((Screen.width - 600) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 500) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 400) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 300) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 200) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 100) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width - 0) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width + 100) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width + 200) / 2, Screen.height - 100, 50, 50), "");
        GUI.Box(new Rect((Screen.width + 400) / 2, Screen.height - 100, 50, 50), "");
	}

You can see that I’m using the GUI.DrawTexture function if the scrabbleTile(texture I want to be drawn) is not null. Well this doesn’t work for me because OnGUI() redraws this texture every frame so what happens is when a second letter is collected the first letter is overwritten with the old one. I want it to be drawn next to the old one and keep the old one. For this too happen I would have to keep this drawtexture function and add another one for each letter that is collected with the right positioning, however I’m not sure how to do this since it’s all happening during runtime. Here are some pictures for reference.

You need an array of textures the same length as the word that you’re going to display so you’ll you have a texture for each box. When you collect a tile you can assign the appropriate texture to its position in the array.

Create an array of textures matching the length of the word:

void Start(){

	// Create an array the same length as the word
	// All elements will be null
	scrabbleTiles = new Texture[numCharacters];
}

When you select a letter you’d assign its texture to a position in the array like

 scrabbleTextures[3] = a;

Then in OnGUI you can iterate through the array and draw the textures that aren’t null

void OnGUI(){

	for (int i = 0; i < scrabbleTiles.Length; i++) {
		if(scrabbleTiles_) GUI.DrawTexture(new Rect(0, 0, 100, 100), scrabbleTiles*);*_

* }*
* }*
You’d need to add some code in there to deal with the position offset of each piece. Hope that makes sense. I need sleep :stuck_out_tongue: