Trying to figure out why, but in formatting my code exactly as shown in the lesson, having my UpdateGridVisual(); in the Start function leads to NullReferenceExeption, unless I lower GridSystemVisual’s priority. Is this something that was mentioned and I missed, or something that is just happening to me?
private void Start()
{
gridSystemVisualSingleArray = new GridSystemVisualSingle[
LevelGrid.Instance.GetWidth(),
LevelGrid.Instance.GetHeight()
];
for (int x = 0; x < LevelGrid.Instance.GetWidth(); x++)
{
for (int z = 0; z < LevelGrid.Instance.GetHeight(); z++)
{
GridPosition gridPosition = new GridPosition(x, z);
Transform gridSystemVisualSingleTransform =
Instantiate(gridSystemVisualSinglePrefab, LevelGrid.Instance.GetWorldPosition(gridPosition), Quaternion.identity);
gridSystemVisualSingleArray[x, z] = gridSystemVisualSingleTransform.GetComponent<GridSystemVisualSingle>();
}
}
UnitActionSystem.Instance.OnSelectedActionChanged += UnitActionSystem_OnSelectedActionChanged;
LevelGrid.Instance.OnAnyUnitMovedGridPosition += UnitActionSystem_OnAnyUnitMovedGridPosition;
UpdateGridVisual();
}
Lowered Priority:
Regular Priority: