Setting a Global "List<string>" 's Length

I’m trying to set the length of a Global string list, but nothing that I do seems to work.

public List<string> InputKeys;// = new List<string>(0);
    private void Awake()
    {
 InputKeys = new List<string>(6); //GameObject.FindGameObjectsWithTag("ControlsInputs").Length);
        //for (int x = 0; x < InputKeys.Count(); x++) { InputKeys.Add(null); } ;
        //SaveControls();
    }

The quotes are some of the things I’ve tried to use, I tried to set the length first then change it, I have also tried to set it in the “Awake” function.

Lists are always empty until you add something to them.

Arrays have a fixed length that you define when you create the array. Maybe you just want to use an array?

public string[] InputKeys = new string[6];
1 Like

Yes, that seems to have worked for me.