public static void LoadLevel(int levelIndex) { if (levelIndex >= 0 && levelIndex < SceneManager.sceneCountInBuildSettings) { if (levelIndex == LevelLoader.mainMenuIndex) { } // for async loading, we need a specific object LevelLoader levelLoader = Object.FindObjectOfType <LevelLoader>(); // load with progress bar if we find a LevelLoad object if (levelLoader != null) { levelLoader.LoadLevelAsync(levelIndex); Debug.Log("Load Level " + levelIndex); } // otherwise load immediately else { SceneManager.LoadScene(levelIndex); } } else { Debug.LogWarning("LEVELLOADER LoadLevel Error: invalid scene specified!"); } }