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

Scene Management

-

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

  1. 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.

Comments (14)

  1. jason_pocketpinata

    Jan 18, 2018 21:07

    2017.3.0f3 Still has this error.

  2. PatrickReynolds

    Nov 17, 2017 14:39

    2017.1.1f1 Still has this error.

  3. Mariochi

    Jun 29, 2017 16:53

    5.6.2f1 error still ocourrs

  4. PerlKr

    May 21, 2017 04:02

    I'm facing that error too. 5.6.0f3

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.