Instead of using the GridSystemVisualSingle I just deactivated the gameobject completely. Is this less performant? Or is there any other reason to use the meshrenderer?
public void HideAllVisuals() {
foreach (KeyValuePair<GridPosition,Transform> a in gridSystemVisuals) {
a.Value.gameObject.SetActive(false);
}
}
public void ShowGridPositionList(List<GridPosition> gridPositions) {
foreach (GridPosition p in gridPositions) {
gridSystemVisuals[p].gameObject.SetActive(true);
}
}
Also I stored the visuals based on the GridPositions in a dictonairy. This way I can easily walk thru all visuals without using the width and height. And all the allowed gridpositions are generated by the GridSystem so the double for-loop is only inside the GridSystem.