using UnityEngine; public class GridLevel : MonoBehaviour { public int stelle; public int breite; public int höhe; public int[] würfelchenLyer1; public int[] würfelchenLyer2; public GameObject block; public GameObject rblock; public GameObject sblock; public int y = 0; void Start() { würfelchenLyer1 = new int[] { 1,1,1,1,1,1,1, 1,3,3,3,3,3,1, 1,3,2,2,2,3,1, 1,3,2,0,2,3,1, 1,3,2,2,2,3,1, 1,3,3,0,3,3,1, 1,1,1,1,1,1,1 }; for (int i = 0; i < höhe; i++) { for (int k = 0; k < breite; k++) { if (würfelchenLyer1[k+(i * breite)] == 1) { GameObject testwürfel = Instantiate(block); testwürfel.transform.position = new Vector3(k, i, 0); } if (würfelchenLyer1[k + (i * breite)] == 2) { GameObject testwürfel = Instantiate(sblock); testwürfel.transform.position = new Vector3(k, i, 0); } if (würfelchenLyer1[k + (i * breite)] == 3) { GameObject testwürfel = Instantiate(rblock); testwürfel.transform.position = new Vector3(k, i, 0); } } } } // Update is called once per frame void Update() { Debug.Log("wert von Würfelchen an der Stelle " + stelle + " ist" + würfelchenLyer1[stelle]); } }