Search Issue Tracker
By Design
Votes
0
Found in
5.6.0b11
Issue ID
896474
Regression
No
SceneManager.GetSceneByBuildIndex().name returns an empty string if scene is not loaded
Reproduction steps:
1. Open the attached project and run any scene
2. See, that .GetSceneByBuildIndex().name returns valid name only for the scene which is loaded
3. You can click "Load next scene" to verify, that it happens on every scene
This bug makes it difficult to retreive all the scene names during runtime
Comments (14)
-
jason_pocketpinata
Jan 18, 2018 21:07
2017.3.0f3 Still has this error.
-
PatrickReynolds
Nov 17, 2017 14:39
2017.1.1f1 Still has this error.
-
Mariochi
Jun 29, 2017 16:53
5.6.2f1 error still ocourrs
-
PerlKr
May 21, 2017 04:02
I'm facing that error too. 5.6.0f3
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Blank, Light-Themed "Create Node" window becomes visible on the next project open
- UI Elements/Layout inconsistencies in the Particle System component
- The Game view and Scene view fail to render when launching the Editor with a maximized Render Graph Viewer window
- "List is empty" is poorly visible in the "Create Node" window
- [Android] GameObject with a custom shader becomes invisible when deployed with the Vulkan Graphics API
Resolution Note:
This is by design because the SceneManager only manages scenes that have been loaded so if it hasn't been loaded yet you cannot query any information from the returned Scene struct. Try checking the scene.IsValid() method before querying any info.
SOLUTION:
You should use SceneUtility.GetScenePathByBuildIndex() instead.
Note you can have scenes named the same at different paths so the path is better to use in general.