Question by
cravioto · Feb 05, 2021 at 03:43 PM ·
array of gameobjects
2d Array vs 3d
Im trying to make a game like bingo but with sprites, 4x4 array. I have a 3d project that works in making the array
But when Im trying to make the same array on 2d (as initially I planned the project), justs displays 1 card at the base of the canvas, and every clone stacked
The prefab script is: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Casilla : MonoBehaviour { public Material colorCasilla; public int NumCasilla = 1;
void OnMouseDown()
{
print(NumCasilla.ToString());
}
public void PonerColor(Material color_)
{
GetComponent<MeshRenderer>().material = colorCasilla;
colorCasilla = color_;
}
} The button for array creation script is: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CrearCasillas : MonoBehaviour { public GameObject CasillaPrefab; public int Ancho; public int Alto;
public void Crear_()
{
for (int i = 0; i < Ancho; i++)
{
for (int x=0; x<Alto; x++)
{
Instantiate (CasillaPrefab, new Vector3(x,i,0), Quaternion.identity);
} } } public void blabla() {
}
}
Thank you!
loteria-3d.jpg
(184.9 kB)
loteria-2d.jpg
(137.3 kB)
Comment
Your answer
