There is a alternative solution for debug keys, you don’t need switching debug if you want be able to finish level and disabling collision detection in one time. This solution is base on Event:
void OnGUI()
{
if(!Debug.isDebugBuild) { return;}
Event e = Event.current;
if (e.type == EventType.KeyDown)
{
switch (e.keyCode)
{
case KeyCode.L:
StartSuccessSequence();
break;
case KeyCode.C:
collisionDetection = !collisionDetection;
break;
}
}
}
And in StartDeathSequence method:
private void StartDeathSequence()
{
if(!collisionDetection)
{
return;
}