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
- Crash on when D3D12RenderPass::SetupDeviceResources when opening FBX animation preview
- Serialization errors are thrown when "com.unity.render-pipelines.core" is added as a custom package and Graphics window is opened
- Character Joints unexpectedly rotate when a ragdoll is created using the Ragdoll Wizard
- Crash on GfxDeviceD3D11Base::DrawBuffersBatchMode when rendering the Scene view
- The shared EditorBuildSettings.asset file of symlinked projects is not updated when changing the order of the Scenes in Build Settings in one of the projects
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.