HI
I am trying to instantiate a 4X4 grid of Ui buttons. these buttons are children of a Panel object. Is ther a cleaner way of instantiating and placing these buttons.
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
private GameObject[] button;
private GameObject panel;
private Vector2 gridSize;
void Start ()
{
gridSize = new Vector2 (4, 4);
panel = GameObject.Find ("PlayArea");
button = new GameObject[16];
for (int i = 0; i < button.Length; i++)
{
for (int x = 0; x < gridSize.x; x++)
{
for (int y = 0; y < gridSize.y; y++)
{
button *= (GameObject)Instantiate (Resources.Load ("Button"));*
_ button*.transform.SetParent (panel.transform, worldPositionStays:true);_
button_.transform.position += new Vector3 ((x * 60) + 150, (y * 80) + 40, 0);
}
}
}
}
}*_