• Runtimes
  • [Unity] Instantiating Spine animation prefabs (FPS loss)

  • Изменено
Related Discussions
...

Hi,

I have got a simple problem. When I instantiate a object from prefabs containing SkeletonAnimation (for the first time) I have huge loss in FPS. See image below

My current workaround is to put object with SkeletonAnimation somewhere in the scene. Then, when I am instantiating new object with the same SkeletonAnimation I do not have loss in FPS. I do not really like this workaround. Maybe there is another possibility to load spine animations to scene before it is loaded?

Thanks.

  • Изменено

If you're only concerned about the delay caused by the first time you instantiate, it's likely the JSON reading. You can load the JSON data in the loading phase of your scene. (You decide how the loading phase works, of course.)

But you can get references to your relevant SkeletonDataAssets and call .GetSkeletonData() on them when your level loads, or wherever loading is appropriate and you don't mind an fps drop.

FWIW, binary should be 5x faster than JSON.

@Nate.
Only it's not. Right now it's not anyway. What was up with that?

wut

Nate написал

wut

Sigh |(

You guys can't say stuff is slow without showing it is slow! 😃 Did you try uncommenting the benchmark code?

oh.

90's sitcom laugh track

Last I saw, the benchmark wasn't showing consistent results, but binary and json was generally taking the same time.
Last I saw.

With Unity, anything is possible.

Thank you all for fast reply :-)
I will start first with SkeletonDataAssets / GetSkeletonData() and then try binary.

Yeah, I think that's a good way to go. You can eventually do both.
Also, sticking with json while you're still in development is helpful if you're using git or some other versioning system.

If you have enough Spine skeletons to load, it may become necessary to preload the textures too. Probably good to hold that off until it's actually an issue though, lest you get obsessed about optimizing non-issues.