What's the special interaction between the Animator and UI.Graphic, and how do i replicate it for other monobehaviors.
When you inherit from UnityEngine.UI.Graphic and create custom serialized properties animating these properties causes the graphic to be redrawn. This is great as you can create custom graphics where you can animate them with these properties.
If I animate a serialized property on a monobehavior however the value changes "Silently" as in if I want to react to a change of a property I have to use unity's Update function, comparing values every frame, even if it is not being animated, this of course is bad for performance and creates hard to maintain code.
I want to be able to detect this change and have some kind of callback/ event that triggers a method so I can react to the property change.
The script I am currently trying to do this on is a script that changes the way a UI graphic is drawn, kind of like a Photoshop effect you can add to a layer, so what I want to be able to do is animate the effect and then get that script to set the effected graphics as dirty so they are redrawn.
The code way to do this normally would be to have the serialized property have an access property that has get and set so that on set it does the appropriate actions, but I can't work out / don't think its possible for an animator to access anything but serialized property's (animation events != to what i want as they don't interpolate or have curves)
My current dirty workaround is to have a serialized float that does noting directly on the graphic ( I call it McGuffin) and animate this between 0 and 1 for the whole duration of the animation. This sets the graphic as dirty and gives me a rebuild for the values that changed elsewhere but obviously this in an extra pointless step that i would like to remove.
I also noticed that animating a RectTransfrom causes a graphic to be rebuilt so it is possible to go between classes somehow. (It triggers RectTransformationChange on Graphics)
Any insights or other workaround suggestions would be appreciated.
Thanks,
Ken
Your answer
Follow this Question
Related Questions
Why does animation event calls twice if put it on certain frames? 1 Answer
Animating multiple materials? 2 Answers
How to animate a MeshRenderer color in Unity3D? 1 Answer
How to make button animation transition to "normal" state instant? 1 Answer
Animation Event not firing or skip problem (When Fast Animation) 0 Answers