Ok,
I am getting the null reference exception for a loop in my OnDrawGizmos() function.
function OnDrawGizmos()
{
for(var i = 0; i < collisionPositions.Length; i++)
{
Gizmos.color = Color.cyan;
Gizmos.DrawSphere(collisionPositions[i], 0.01);
}
}
These errors are coming up while in edit AND game mode. This has never happened to me before – help?
valax
2
Which part of the code is giving you an error?
Dantus
3
It must be line 3, meaning the collisionPositions array is null.
function OnDrawGizmos()
{
if (collisionPositions != null) {
for(var i = 0; i < collisionPositions.Length; i++)
{
Gizmos.color = Color.cyan;
Gizmos.DrawSphere(collisionPositions[i], 0.01);
}
}
}