Strange behaviour when trying to access a list from a variable

Hi,

I have a variable that has a empty list:
8688054--1171830--upload_2022-12-26_21-33-43.png

When I try to access any property of that variable, it works fine, but for the list, I get an error:

How is that possible to access one property and not the other? UpgradeList is not Null, it’s an empty list and Count Items function should return 0.

The weirdest part is that the game object that has the script and variable was instantiated on the runtime from a prefab that is exist in the scene. However, in that prefab, I get the expected result:

Even if you have just a guess, please write it below, because this is driving me crazy.

Thanks

Looks like the list might not be initialized in C# code.

Try:

public List<T> UpgradeList = new List <T>();

this should also work in newer Unity versions:

public List<T> UpgradeList = new();

It solved the issue. Thank you so much! :slight_smile: