- Home /
Dynamically adding members accessible by animation system?
I've got a use case where I'm reading in a custom model asset type, and then pulling some values from that file and storing them in a list in the final script. I'd like these assets to be animatable, but it appears you can't animate the contents of a collection in Unity. These values are not set in stone, so they will be of variable length and the names will be different every time, so I can't just hard-code a class to represent them.
Solutions I'm looking at:
Using the System.Reflection.Emit library to generate a new child class with the members I need. Might work but Unity might not like me deleting and creating classes on the fly with it's serialization system?
Write a script that generates the class I need by writing out the file line-by-line. Less than ideal because changing this code in the future will be a lot of work, and it's quite fragile.
I don't like either of these solutions, so I wanted to see if somebody could help me out .. I've ran out of ideas. Thank you for reading.