- Home /
Debug.Log prints only sometimes.
Hello! My Debug.Log behaves very weirdly. Here is my code.
if (adjacent.iteration != iteration || adjacent.status == Cell.Status.Default)
{
Debug.Log("New: " + adjacent.cellPos);
adjacent.iteration = iteration;
adjacent.given = cell.given + 1;
adjacent.cost = adjacent.given + DistanceBetween(adjacent, end);
adjacent.parent = cell;
adjacent.status = Cell.Status.Open;
q.Insert(adjacent);
Debug.Log("Insert: " + q.Size());
}
There are three Debug.Logs on this code. One is at the top, another one is at the bottom, and the other one is inside q.Insert() method. They are consecutive codes, so they should always print together, but only first one prints constantly. The others don't print anything sometimes.
During "New: " printed 4 times, "Added" printed only once, and "Insert: " printed only 3 times (it did not print anything at the last). I can't understand how it is possible.
Here is implementation of q:
public class PriorityQueue
{
private SortedSet<Cell> cells = new SortedSet<Cell>(new CellComparer());
public void Insert(Cell cell)
{
cells.Add(cell);
Debug.Log("Added");
}
}
Thank you for reading and I'll welcome any suggestions. Thank you!
Answer by Mrpxl · May 21, 2021 at 08:10 AM
My guess is that you have "Collapse" enabled in your console. Collapse will group identical logs together