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
-
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
- Standalone Player crashes with "TDerived GetOrLoad<TDerived>() where TDerived : T" when IL2CPP Code generation is set to "Faster (smaller) Builds"
- IndexOutOfRangeException and InvalidOperationException when logging XML string
- Script missing in "Assets/Settings/Mobile_Renderer/GlobalVolumeFeature" of "com.unity.template.urp-blank" template
- “Font Asset Creator - Error Code [Invalid_File_Structure]…“ error is logged when generating Font Assets from fonts with meta files from previous Editor versions
- Input.mousePosition returns (NaN, NaN, 0.00) when Scene view is opened
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.