using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class GridGeneration : MonoBehaviour { [SerializeField] private int _width, _height; [SerializeField] private Tile _tilePrefab; public Material[] tileTextures; // Start is called before the first frame update public void GenerateGrid() { if (_tilePrefab == null) { Debug.LogError("No Tile prefab found. Please insert prefab in field."); return; } var tileParent = new GameObject("Tile Parent").transform; for (int x = 0; x < _width; x++) { for (int z = 0; z < _height; z++){ var tileBound = _tilePrefab.GetComponent().bounds.size; Debug.Log(x+tileBound.x + z+tileBound.z); var spawnedTile = Instantiate(_tilePrefab, new Vector3(x*tileBound.x, 0, z*tileBound.z), Quaternion.identity, tileParent); spawnedTile.name = $"Tile {x} {z}"; spawnedTile.GetComponent().myManager = this.gameObject; } } } //void Hiearchy(){ // var hierarchyDiv = new GameObject("--- Level ---").transform; // } }