you don’t have to allocate Lists
you just do new List() to have a reference to a List instance of type Weapon. List are dynamic so you can List.Add, List.Remove, …
The list hasn’t been populated, so it shows you the zero, or first, member of the list in the editor. Just click on the little arrow and fill it in, and you can add another.
The capacity is not the same thing as size, and has to do with pre-allocating memory. Normally you’ll never set the capacity, but there are cases where its useful.
To create a list with two weapons, you can write (I edited this to Timelog’s suggestion below):
List<Weapon> weapons = new List<Weapon> { new Weapon(), new Weapon() };
Or, if you want a solution that will take a number as the quantity (this can be useful if the size is a variable or constant), add this to the top of your script:
using System.Linq;
…and to declare your list:
List<Weapon> weapons = new List<Weapon>(Enumerable.Range(0, 2).Select(i => new Weapon()));
My initial instinct was to use Enumerable.Repeat, but this will only create one Weapon and assign it to both array indexes. It’s useable for value types though.
Finally, I noticed you named the list “weapon”. I really suggest naming it in the plural form of “weapons”.
hmm, a serialised class will show up in your list in the inspector, but won’t be editable.
If that’s what you want have a look into Scriptable Object. chances are you’ll have to make a custom editor/inspector window to create and edit an instance of your class.
Basically, if you declare something like: public int hest = 3; it shows up in the inspector with a value of 3 (which you can then change). Shitman wanted to declare a public list of Weapon, and have it by default show up in the inspector with a pair of Weapon before he made any changes to it. Given his code example, he mistook capacity for size (a mistake I also made the first time I tried to create a list with a specific size).
The solutions in my post (which Timelog corrected) will work.