Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Today mostly toying with some grid creating logic to make grids where I can reference any cells I need. Y'know, for random level generation and stuff :D

Never done that before, so its goin pretty slow xD

Here's what I have rn: 

using System.Collections; 
using System.Collections.Generic; 
using UnityEngine; 
using UnityEngine.UI;  
public class PointSetter : MonoBehaviour 
{          
public GridLayoutGroup _grid;     
public RectTransform _gridRectTransform;     
public Vector2 _gridSize;     
public float _gridSizeMultiplyer;     
public float _cellSize;     
public GameObject _cell;     
public List<gameobject> _cells;     
public List<vector2> _cellPositions;      
private void Awake()     
{         
SetPoints();         
Debug.Log($"{_gridRectTransform.rect.size}");     
}     
public void CellSetter()     
{              
}         
public void SetPoints()     
{         
_grid.cellSize.Set(_cellSize, _cellSize);         
Vector2 gridSize = _gridSize * _cellSize * _gridSizeMultiplyer;         
_gridRectTransform.sizeDelta = gridSize;         
int cellcount = (int)(gridSize.x/ _cellSize * gridSize.y / _cellSize);         
Debug.Log($"{cellcount} cells");         
for (int i = 0; i <= cellcount; i++)         
{             
GameObject newCell = Instantiate(_cell, _grid.transform);             
_cells.Add(newCell);             
_cellPositions.Add(newCell.transform.position);         
}         
_grid.enabled = false;         
for (int i = 0; i < _cells.Count; i++)         
{             
_cells[i].transform.position = _cellPositions[i];         
}     
}      
public void OuterLayers()     
{         
var LeftestColumn = _cells[0];         
var TopRow = _cells[0];         
var RightestColumn = _cells[(int)(_gridSize.x * _gridSizeMultiplyer)];         
var BottomRow = _cells[(int)(_gridSize.y * _gridSizeMultiplyer)];      
} 
} 

Aaaand I pretty much wasted my time on this one. Started over :D