Animation changed callback?

Hi guys,
I’ve a custom script that need to take action as soon as a parameter is changed by the animator.
I’ve a cached copy of all my animable variables and in the OnDidApplyAnimationProperties() callback, I check if there is any change and take action if happen.
The big problem is when the animator change animation and fill my script with completely new data, but doesn’t call the callback this time (by design …)
Since I can’t use an Update to check each frame if something has changed, do you know any other way to get the job done?

Thanks!

2 Likes

Why not?

Because I’ve hundreds of these components in scene and I’m on mobile, so for performance reason.

Then just use one component with a list of all the others. Most likely it wouldn’t matter anyway. Several hundred update calls is still probably going to be small compared to the cost of actually having those models on screen and running their Animator Controllers.

Three years later - is there a solution for this by now?

Unity has added the possibility to have field “properties” like this
[field: SerializeField] public float my_property { get; set; }
and this shows in the inspector. However that doesn’t support actually adding a method content to the getter or setter. It’s merely for making things private…

Anybody have an idea?

I do have the same issue that I wanna avoid comparing about 30 variables every frame for whether they have changed. That’d be quite ridiculous for something that feels so trivial.