-
::Based on the context, here are potential issues to investigate:
-
Ensure sceneName
is being properly set during the editor preparation:
public void PopulateLevelsList()
{
#if UNITY_EDITOR
foreach (SceneAsset map in maps)
{
selector.levels.Add(new UILevelSelector.SceneData
{
scene = map,
sceneName = map.name, // Explicitly set scene name
label = mapLabel,
displayName = mapName
});
}
#endif
}
-
Add debug logging in the LoadSelectedLevel()
method:
public void LoadSelectedLevel()
{
if (selectedLevel >= 0)
{
string sceneToLoad =
#if UNITY_EDITOR
levels[selectedLevel].scene.name
#else
levels[selectedLevel].sceneName
#endif;
Debug.Log($"Attempting to load scene: {sceneToLoad}");
SceneManager.LoadScene(sceneToLoad);
// Rest of existing code...
}
}
Could you confirm:
- Are the
sceneName
values exactly matching the scene names in Build Settings?
- When you run the build, do you see any console logs or errors related to scene loading?