• Runtimes
  • Is there a way to pause/resume anim OnBecane[In]visible?

Related Discussions
...

Hi all!

I'm wondering if Is there a way to pause/resume animations OnBecane[In]visible with Unity runtimes.

In our current game almost all is done using spine animations, then there are hundreds of objects playing skeletal animations and the profiler shows that:

  • SkeletonRenderer.LateUpdate() consumes between 40-45 % of time
  • SkeletonAnimation.Update() consumes between 18-21 % of time

I think it would be useful to pause some animations, like coins for example, or maybe some enemies...

Any solution?

Thanks in advance!


Hello again!

I have made a quick and dirty test. I add two functions to SkeletonAnimation class:

public void OnBecameInvisible() {
   valid = false;
}

public void OnBecameVisible() {
   valid = true;
}

And now:

  • SkeletonRenderer.LateUpdate() consumes between 12-14 % of time
  • SkeletonAnimation.Update() consumes between 4-6 % of time

But I think that it should not be very safe to do so. What do you think?

Just enable/disable the SkeletonAnimation component itself?

It works but It seems a bit less effective.

  • SkeletonRenderer.LateUpdate() consumes between 20-21 % of time
  • SkeletonAnimation.Update() consumes between 7-9 % of time

Thanks!

Umm. If you disable SkeletonAnimation component it consumes 0% of the time.

Maybe it's because disabling 'valid' affect other scripts.

At this point I added a new flag called isVisible to SkeletonRenderer that is disabled in Reset, enabled/disabled OnBecane[In]visible and checked at every [Late]Update() and I get the best permormance. From 30-60 FPS to 250-1000

Now I can add more spine objects without fear ^_^

What are you making that has that many spine objects?!

A 2D game