Creating dynamic number of [AnimatableParameters]

Slate Forums Support Creating dynamic number of [AnimatableParameters]

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2294
    brodyb
    Participant

    Hey there!

    Something I want to accomplish with a Slate clip is to allow the user to create new Animatable Parameters on the fly using the Inspector. Internally, I’d have a list of instances of a data class like:


    [System.Serializable]
    public class EffectParameter
    {
    public string name;
    [AnimatableParameter]
    public float value;
    }
    <code></code>

    In the Inspector, the user can add new instances of this with a given name, and it would generate a new Animatable Parameter track on the clip. I’m doing this to tie into Visual Effects parameters, which are all user-defined and Unity doesn’t let you get the list of those conveniently, but that’s another story.

    Likewise, if you delete one of these EffectParameter instances, I’ll remove that Animatable Parameter track.

    Is this something that’s possible to achieve?

    Thanks!

    #2298
    Gavalakis
    Keymaster

    Hello there!

    The short answer is that unfortunately Lists of parameters (or lists of classes with parameters in this case), are not supported right now. However, adding dynamic parameters is in a similar fashion to how it is done with the AnimateProperties clip, is.

    The catch here is that for an AnimatableParameter to be registered/added (look at “AnimationDataCollection.TryAddParameter” method), a member path targeting a field or property has to be provided as well. However, the problem here is that all the code related to member paths, does not handle lists at all and it was quite tricky the last time I gave it a try, but didn’t end up pursuing it further since I didn’t had a use case for it at the time for any clip.

    So, to achieve what you want I will basically need to refactor all code related to member paths so that lists are supported, which admittedly I find it useful. As I stated earlier it was quite tricky to do the last time I gave it a try, but if this a must have feature for you, I will gladly give it another sooner 🙂

    Let me know.

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.