Reputation: 189
GameObject[] buttonarray = new GameObject[100];
GameObject[] textarray = new GameObject[100];
Initially I was going to individually make 100 text game objects and 100 button game objects.
Then I realized that I can make an array of each. Now I'm stuck since I'm not sure how to add the buttons or text to the array.
I want to make the grid randomize an integer onto the text on the screen and have the user click it that many times until it becomes zero. Once all of them are clicked the user wins. This is how I was able to make the grid.I made them into panels and each panel with 10 buttons.I'm new to Unity so please let me know if there is a another way I might do this in unity itself.
Upvotes: 2
Views: 3779
Reputation: 5035
There is a GridLayout component that you can use:
It works using the UI/Canvas, so it might need a canvas, but you can make a world space canvas with no UI rendering objects and still use it
Upvotes: 3
Reputation: 41
There is a component you can add to the parent object of the buttons, if none exists create one. The name of the component is escaping me at the moment however it you just search in the component field you should find it with "grid" or "layout".
What it will do is space the elements equally to your liking.
Upvotes: 0