Possible to know if Animator is being culled via Script?

When I change the culling type on an Animator to Cull Completely, I can see in the profiler that the Animator.ApplyOnAnimatorMove removed the object when it is no longer in the camera view.

I’d like to optimize some logic in a script based on if we aren’t animating, but I couldn’t see any property on the Animator that would tell me if it’s animating or being culled or not.

Does that exist?

1 Like

yes basically the animator does register itseft to all renderer found under the animator component
And then renderers send the appropriate msg when they become visible or not.
If any renderer are visible then the animator need to be updated

you can attach your script to the same callback

3 Likes

I tried and it works as @Mecanim-Dev says, the only problem is that the GameObject where the Animator is, has to have a Renderer, and maybe you only want Renderers on the children.

Maybe should be better explained on OnBecameVisible() documentation that Animators also have this feature.

Keep in mind as well that you cannot check that culling behaviour on Editor View, because it is considered a Camera. To make sure it works, I have a look at the transforms of objects outside any camera / view to see if they where moving.

Hope it helps.

Thanks anyway!

Can someone confirm the correct behaviour ?

  • Animator culls with renderers in the child hierarchy of the animator
    or
  • Animator culls with the renderer on the GO itself ? (That would be damn wierd …)

However I do have this issue where my animators are culled although they child renderers (Sprite Renderers) are in full view. I believe it’s kindof a “bug” as :

At start of the animation the child renderers are of size 0.001 and this prbly randomly discarded as being visible and so the animator discards itself without the chance to scale up the child renderers.

As far as I can tell this is not the case. I tried putting those callbacks on the same object as the Animator and they are not called.