Here is my solution:
private void LoadNextScene()
{
switch (state)
{
case State.Alive:
break;
case State.Dying:
SceneManager.LoadScene(0);
break;
case State.Transcending:
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
int maxSceneCount = SceneManager.sceneCountInBuildSettings;
int newMax = maxSceneCount - 1;
print(newMax);
if (currentSceneIndex >= newMax)
{
SceneManager.LoadScene(0);
}
else if (currentSceneIndex <= newMax)
{
print(maxSceneCount);
int nextSceneIndex = currentSceneIndex + 1;
SceneManager.LoadScene(nextSceneIndex);
}
//int nextSceneIndex = currentSceneIndex + 1;
//SceneManager.LoadScene(nextSceneIndex);
//SceneManager.LoadScene(1);
break;
default:
break;
}
}