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
- Tile Palette grid is moved after entering Play Mode
- Tile Palette Edit mode turns off in Play Mode
- The Editor crashes when Generating Font Atlas in the Font Asset Creator with “9999999999” padding and 256x256 Atlas Resolution
- [iOS] An “ArgumentNullException” error is thrown when GetIntroductoryPriceDictionary() method is called
- Font Import Settings documentation page is missing when the documentation button is pressed in the Inspector window
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.