Eonirr

Untitled

Mar 13th, 2026
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. bool isSceneExists(string sceneName)
  2. {
  3. for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
  4. {
  5. string path = SceneUtility.GetScenePathByBuildIndex(i);
  6. string name = System.IO.Path.GetFileNameWithoutExtension(path);
  7.  
  8. if (name == sceneName)
  9. return true;
  10. }
  11. return false;
  12. }
  13.  
  14.  
  15. // And then Just
  16. if (isSceneExists("yourSceneName"))
  17. {
  18. SceneManager.LoadScene("yourSceneName");
  19. }
  20. else
  21. {
  22. // what you want
  23. }
Advertisement
Add Comment
Please, Sign In to add comment