Procedurally generate GUI objects?

Hi all! I’m have a bit of trouble understanding GUI objects and more importantly if they’re the correct object type for the problem I’m trying to solve. If there’s a better way of doing this, please direct me to it, but GUI elements was the first idea I had.

Basically, I want a game element to be represented on the screen by a drawn object that displays information from the game element it is representing such as a name and a description, and I want to be able to generate these procedurally by passing it the information it needs, as they will mostly be just visual representations for work that is being handled by code and will be created and destroyed a lot.

So if anyone could point me in the right direction of an elegant way of solving this it’d be greatly appreciated. :smiley:


Generating basically means rendering amount of certain times, if that amount changes so does amount of gui elements. That value can be array length (for inventory for example) and so on. You will also have to handle correct elements positioning.
Something simple, change the value from inspector an amount of elements will change.

public int amount;
private Rect rect_test = new Rect(0,0,20,20);

private void OnGUI(){
	if(amount > 0){
		for(int i = 0; i < amount; i++){
			rect_test.x = i*22;
			GUI.Box(rect_test, i.ToString());