for (int i = 0; i < Targets.Count; i++)
{
if (Targets == null)
{
Targets.RemoveAt(i);
}
}
If you erase a gameobject out of the scene then the code will not evaluate it as “null”. Missing ()
is something other than null.
How do we handle this case?
How do you remove from Scene ?
Destroy() doesn’t destroy the object immediately. Instead use DestroyImmediate().
Read here more.