I’ve been trying to create an array of prefabs based on some answers I found here, but I’m not having any luck. I keep getting a null reference error. I’m sure this is a simple problem, but I’m a noob and can’t solve it. Any help would be greatly appreciated.
Here’s the code i have so far:
public GameObject[][] tiles_array;
public GameObject tilePrefab1;
public int boardWidth = 32;
public int boardHeight = 32;
float tileWidth = 5.0f;
float tileHeight = 5.0f;
void Start () {
Debug.Log("fart");
tilePrefab1 = Resources.Load("tilePrefab1", typeof(GameObject)) as GameObject ;
for (int i = 0; i < boardWidth; i++)
{
tiles_array *= new GameObject[boardWidth];*
-
for (int j = 0; j <boardHeight; j++)* -
{*
tiles_array_[j]= (GameObject)Instantiate(tilePrefab1, new Vector3(itileWidth,jtileHeight,-2), Quaternion.identity);_
* }*
* }*
}