Determine invalid scene

Hi,

I’m using SceneManager.LoadAsync to load new levels which are somewhat determined by user input, and I can’t seem to determine how to assess if a scene is valid or not before I load it.

Is there a way to determine if a scene name is valid? I know you can do EditorBuildSettings, but UnityEditor doesn’t function outside of the editor. I need something that will work in a WebGL build.

Nick

Any help?

Well, you could ham together your own solution.

Simply create a List, add your scene names to that List, and then check if the inputted name is in your List.

For example:

public List<string> TestSceneList;
public string UserInputSceneName;

void TestListVerifier()
    {
        if (TestSceneList.Contains(UserInputSceneName))
        {
            Debug.Log("List has a match!");
        }

        else
        {
            Debug.Log("INVALID SCENE NAME");
        }
    }

To add to a list, you can do TestSceneList.Add(“A name”);

Yeah, this is basically what I’ve done, but it involves a fairly bad solution (i.e. hardcoding scene names in my code).

So there is no way to get the list of scene names in the deployed code?

Actually, it’s not that bad. This is a more clever solution: http://stackoverflow.com/questions/36071344/getting-scene-names-at-runtime-creating-scenes-at-runtime