Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Get the name of an unloaded scene from SceneManager?

Discussion in 'Scripting' started by NeilM0, Dec 15, 2015.

  1. NeilM0

    NeilM0

    Joined:
    Mar 31, 2009
    Posts:
    135
    How can I get the name of a scene without loading it using the new SceneManager?

    I've created two scenes. SceneA and SceneB and added them both to the build settings.

    Code (CSharp):
    1. Debug.Log(SceneManager.sceneCount);
    This returns 1. Only SceneA is loaded.

    Code (CSharp):
    1. Debug.Log(SceneManager.sceneCountInBuildSettings);
    This returns 2.

    Code (CSharp):
    1. Scene[] all = SceneManager.GetAllScenes();
    This returns a 1 element array containing SceneA.

    I know I can load based off of the build settings index, but is there any way to find the name of the scene without loading it?
    Am I just missing something basic?
     
  2. MihaPetelin

    MihaPetelin

    Joined:
    Oct 3, 2014
    Posts:
    1
    TaleOf4Gamers likes this.
  3. a_p_u_r_o

    a_p_u_r_o

    Joined:
    May 27, 2015
    Posts:
    20
  4. gwang2

    gwang2

    Joined:
    Jun 14, 2017
    Posts:
    2
    Keepabee, barbelot, homemacai and 4 others like this.
  5. Miestry

    Miestry

    Joined:
    Mar 21, 2020
    Posts:
    2