- Home /
Question is off-topic or not relevant
List as property?
Hi there,
I have a List and wonder if I can create a property for the List? Visual Studio 2017 creates this with auto-generation:
private List<MyObject> objectsList = new List<MyObject>();
public List<MyObject> ObjectsList { get => objectsList; set => objectsList = value; }
But that doesn't seem to work. I use a self created get method now, but I'm just curious.
But that doesn't seem to work
This is not a sufficient description of your problem. Of course you can create a property of any kind of type. The property mechanic always works the same. Why do you actually create a setter for your list? It's possible but usually not required / used especially since you create the list already yourself.
Without more details on the actual problem we have to close this question as it can't be answered.
Please edit your question and add more details.
$$anonymous$$y guess would be that you think it doesn't work because you cannot see it in the Inspector. That's correct with a property because Unity cannot serialize them.