Unity-Reorderable-List icon indicating copy to clipboard operation
Unity-Reorderable-List copied to clipboard

List of base class does not draw the inheritance attributes

Open RotcivOcnarb opened this issue 4 years ago • 1 comments

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?

RotcivOcnarb avatar Feb 24 '21 16:02 RotcivOcnarb

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?

cfoulston avatar Apr 06 '21 18:04 cfoulston