using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;

public class FillDopdownWithScenes : MonoBehaviour
{
    public TMP_Dropdown dropdown;
    private void Awake()
    {
        PopulateWithScenes();
    }

    void PopulateWithScenes()
    {
        dropdown.ClearOptions();

        List<string> sceneNames = new List<string>();

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            string path = SceneUtility.GetScenePathByBuildIndex(i);
            string name = System.IO.Path.GetFileNameWithoutExtension(path);
            sceneNames.Add(name);
        }

        dropdown.AddOptions(sceneNames);
    }
}
