Hello, I am currently working on an app, but to use it prroperly i need to generate some “Buttons”, this buttons involves some text, images… I want to use template so it all looks the same but there is some spacing between it. I would like to use foreach statement. If you have any script that is doing this function, please respond, all love-me!
Show us your work so far.
Do you mean script or?
Create prefab of this button with text and image.
Add Grid/Vertical/Horizontal Layout Group component to gameObject and instantiate as much buttons as you want with Layout Group gameObject as parent.
public MyButton prefab;
public Transform root;
for(int i = 0; i < 5; i++)
{
var button = Instantiate(template);
button.InitSomehow();
button.transform.SetParent(root);
}
1 Like
Thank you, this helped me a lot!!! <3