I am making a project where I need to keep track of the buildings placed in each cell. I want to hold the cells in a list, but whether I try to use Start or Awake, absolutely nothing prints to the Log. I have read other threads similar to this suggesting that the script or game object is turned off, or that the script is not attached to the game object, and I have made sure that all that is as intended. I have even tried messing with script execution order, but nothing has worked so far. Any help is appreciated, and the code in question is below.
public class BuildingsManager : MonoBehaviour
{
private static int sizeX, sizeY = 9;
private static int height = 5;
private static List<Vector3> openCells = new List<Vector3>();
private static List<Vector3> takenCells = new List<Vector3>();
void Awake()
{
for(int x = 0; x < sizeX; x++)
{
for(int z = 0; z < sizeY; z++)
{
for(int y = 0; y < height; y++)
{
openCells.Add(new Vector3(x - 4, y, z - 4));
Debug.Log(openCells.Count);
}
}
}
}
There’s a debugger in your IDE. Attach it, set a breakpoint, step through lines of code as they execute, and inspect any variable in scope. Imagine how useful that is!
I often wonder why Unity developers don’t use the VS Debugger and Breakpoints? Remind me of frontend web developers with their console.info(“reached this line”) on each line… Apparently it’s an industry wide problem according to the legendary John Carmack (at 1:25):
Back in the stone age Unity didn’t have a debugger and so the troglodytes figured out ways of debugging by simply staring at their code and stepping through it in their heads. And as we know, old habits die hard…
And I think for a lot of users just getting Visual Studio Code and intellisense to work is more than enough stress for them.