Where to Store all my scene name correctly

I am making a project in Unity, and would like to have one place to access all my SceneNaming;

Right now in the UI, every button I have to manually set the name with a string, if I edit the scene name it will brake.

I would like to store all my scene name in an object, so that I can just use a drag drop to choose all my scenes names.

I tried the following

Put a static class and have then like this, it’s ok to call them from scripts, but not if I call them via inspector button

public static string SCENE_MENU = "Menu";

public static string SCENE_WORLD = "Demo";
  1. Inside an enum, same as above

    public enum SCENE_NAME{

    Menu, Demo


  2. Inside scriptable object, I make a scriptable object per scene, with the name, and just drag that object in every button.
    But this method do not work in code.

What do you sujet? how do you manage those kind of stuff?

I’ll tell you a really straightforward solution using your 2nd approach:

public enum SCENE_NAME {
   // so on...

public class ButtonScript : Monobehaviuor {
      public SCENE_NAME sceneName;
      public Text buttonText; //your buttons text component

      void Awake (){
            buttonText = //GetComponent<Text> whereever it is

      void Start(){
           buttonText.text = sceneName.GetDescription();


public static class EnumExtensions {
        public static string GetDescription(this Enum value) {
            System.Reflection.FieldInfo fi = value.GetType().GetField(value.ToString());
            System.ComponentModel.DescriptionAttribute[] attributes = (System.ComponentModel.DescriptionAttribute[])fi.GetCustomAttributes(
                typeof(System.ComponentModel.DescriptionAttribute), false);
            if (attributes != null && attributes.Length > 0)
                return attributes[0].Description;
                return default(string);

You will attach ButtonScript to each button and select the enum type of your button. At runtime it will get the button name from the description attribute via the GetDescription() extension method. This way you could select the name of your button both from inspector or in the code. And when you want to change the name of your button without breaking any reference, just changing the description will do.

open up your build settings and add all open scenes (which may mean you have to add open a scene then add open then add etc or just do scene additive (don’t do that if you’re not used to unity yet, freaked me out first time i did it)).

that will assign each scene an int, then i just put this script on what ever button i use to go to another scene

public MainMenuButtons start;

private void Awake()

    if (start == null)
        start = this;
    else if (start != this)
    //call load method

//this int sceneID is the int that the scene was assigned when you added it in your build settings, you'll need to know what each scene ID is
public void GoToScene(int sceneID)

then in the editor on your button, click on the plus sign under the “On Click()”

drag the script that you put on this button into that little box that is “missing object”

click the little drop down menu in this on click box and hilight MainMenuButtons and choose GoToScene()

then it will allow you to assign which int you want that button to go to based on the int

so i have a start button a shop button and a tutorial button

main menu is 0
start 1
shop 2
tutorial 3

this lets me add as many scenes as i want and just simply add the same script anywhere and tell that button to go to that place.