cfoulston / Unity-Reorderable-List

Extended version of the Reorderable List in Unity
https://forum.unity3d.com/threads/reorderable-list-v2.339717/
MIT License
638 stars 97 forks source link

List of base class does not draw the inheritance attributes #32

Open RotcivOcnarb opened 3 years ago

RotcivOcnarb commented 3 years ago

Have I written this title correctly?

Suppose I have a class Prize, and I want to make a Reorderable List for it. image Now I have different types of Prizes that each has its own class that inherits from Prize, for example CoinPrize, that besides having the original attributes, also have a amount attribute, that I want to also modify in the inspector.

Since obviously you can't add items to the list and expect the class to magically know what type of item you want, I have create separated buttons, each that adds a specific class child for the list image

But in the inspector, even if adding the element via the correct button, the child class attributes doesn't show up:

image

Is there any way I can make this work?

cfoulston commented 3 years ago

I believe you need to use the new [SerializeReference] attribute on your list. What happens if you remove the Reorderable list? Does the functionality of adding and drawing different prizes into the list work?