HI! I’m trying to make a Dynamic Grid button system.
It searches for the number of objects with tag “UserFighter” and creates a grid of buttons based on rthe number of fighters it finds so it can dynamically add new content as it is found,
using UnityEngine;
using System.Collections;
public class UserShipSelect : MonoBehaviour
{
// finds all Userfighters and builds a table based on number of fighters.
// orders fighters by number and loads images into button gridd.
public string[] selStrings = GameObject.FindGameObjectsWithTag("UserFighter").Length; // Find UserFighter Count.
void Start ()
{
// Find all images relevant to fighetrs.
}
void OnGUI() {
GUILayout.BeginVertical("Ship Select");
selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
if (GUILayout.Button(""))
Debug.Log("ShipSelect" + selStrings[selGridInt]);
GUILayout.EndVertical();
}
}