Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isSceneExists(string sceneName)
- {
- for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
- {
- string path = SceneUtility.GetScenePathByBuildIndex(i);
- string name = System.IO.Path.GetFileNameWithoutExtension(path);
- if (name == sceneName)
- return true;
- }
- return false;
- }
- // And then Just
- if (isSceneExists("yourSceneName"))
- {
- SceneManager.LoadScene("yourSceneName");
- }
- else
- {
- // what you want
- }
Advertisement
Add Comment
Please, Sign In to add comment