Andrio Andrio - 4 months ago 35
C# Question

Get name of next Scene in build settings in Unity3D?

So, what I want to do seems like it should be extraordinarily simple. I need to grab the name (not load it) of the next scene, as listed in the build settings.

I thought I had a simple solution by doing something like this:

int currentIndex = SceneManager.GetActiveScene().buildIndex;
string nextSceneName = SceneManager.GetSceneAt(currentIndex + 1).name

But apparently that "GetSceneAt" doesn't apply to the scenes in the build settings, instead it's for some kind of internal list that the SceneManager has.

All my google searches bring up solutions based on a specific naming order for your scenes, or exporting the list of scenes to a file before building (a list that manually needs to be exported), etc. I can't imagine such a simple problem requires such a complex solution, which is why I'm asking for myself.

How can I just grab the name of the next scene in the build settings?


Yes unfortunately you are right, but...You're in luck!

I created a plugin/asset for that after reading your question, it's three small scripts and it should 'just work' and using it is literally just one line of code:

var buildSceneRecords = BuildScenes.Records;

The records contain the name, path and index for the scenes in the editor build settings.

You can get it here: