declare list of class 'command' so I can select them as part of class ' button' in the inspector

Hi I have a request for some basic CS help…

I have this class in my CommandManager script:

[System.Serializable]
public class l2gx_command
{
    public string commandName;
    public bool isToggle;
    public float commandTimer;

    public l2gx_command(string command_name, bool toggle, float command_timer)
    {

        commandName = command_name;
        isToggle = toggle;
        commandTimer = command_timer;
    }

}

which is called in this class in the ButtonManager script:

[System.Serializable]
public class l2gx_button
{
    public GameObject buttonObject;
    public Vector2Int xSize; // this shows the leftmost square, then the rightmost square
    public Vector2Int ySize; //this shows the lowest square, then the highest square.
    public string buttonName;
    public l2gx_command command;


    public l2gx_button(GameObject new_buttonobject, Vector2Int new_vector2Int_X, Vector2Int new_vector2Int_Y, string button_name, l2gx_command _command)
    {
        buttonObject = new_buttonobject;
        xSize = new_vector2Int_X;
        ySize = new_vector2Int_Y;
        buttonName = button_name;
        command = _command;
    }
}

What I get in the Unity inspector is this:

7603075--943846--upload_2021-10-26_11-2-9.png

But what I’d like to do is declare a list of l2gx_commands in the CommandManager and have them selectable in the inspector for the ButtonManager script. Any tips as to where to go would be very appreciated!

Ultra-simple solution is to use an enum type, but they can have issues with serialization:

It is much better to use ScriptableObjects for many enumerative uses. You can even define additional associated data with each one of them, and drag them into other parts of your game (scenes, prefabs, other ScriptableObjects) however you like. References remain rock solid even if you rename them, reorder them, reorganize them, etc. They are always connected via the meta file GUID.

For the latter, your l2gx_commands would each be ScriptableObject instances named as files in your project.

Once you have that going, there are a bunch of different ways to make those accessible, ranging from the trivial by making a public field of that type, which lets Unity be the pick list, to writing miles of custom editor code to make a popup list, which may or may not be worth it to you.