• Unity
  • [Unity] SkeletonRenderer LateUpdate() too slow?

  • تم التحرير
Related Discussions
...

I use asynchronous loading for spine datas. ( json, atlas, png ).
But when first time creating spine, it still cause lag in SkeletonRenderer LateUpdate().
One for about 250ms delay, 10 for 2.5 seconds delay. 😢 😢 😢

Code snippets:

var obj = new GameObject();
var animation = obj.AddComponent<SkeletonAnimation>();
animation.skeletonDataAsset = asset;
// ... something else
// Big lag: Call SkeletonRenderer LateUpdate()
animation.Reset();   

Unity Version: 4.6.0f3

I have found that someone with the same question in this post:
http://esotericsoftware.com/forum/Unity-SkeletonRenderer-rebuilds-everything-each-frame-4466?p=21465&hilit=lateupdate#p21465

This problem has bothering me several months, is there a good solution yet? :think: :think: :think:
Thank you!

In what way are you doing asynchronous loading?
Note that it's not enough to "load" the SkeletonDataAssets through LoadAsync or something.
You need to make them generate the Skeleton objects during your load phase/load scene.
You do this by calling, on each of them, something like:

mySkeletonDataAsset.GetSkeletonData(false);

This method lazy-instantiates the actual skeleton data, and triggers the reading of the json/binary files.

You may also need to tell Unity to preload the materials/textures too. I'm not sure how to do that, but that's a Unity thing. You can probably search the Unity forums for that. I've never done it myself.

I also think that thread you linked has little to do with your problem. (but in case you're interested, some 20 to 40% mesh-updating performance gains are being worked on. Someone just contributed some changes to the code that works around some weird stuff Unity does.)

Pharan wrote

but in case you're interested, some 20 to 40% mesh-updating performance gains are being worked on. Someone just contributed some changes to the code that works around some weird stuff Unity does.

I was wondering, are the 20-40% mesh updating improvements mentioned going to be merged soon before any big Spine 3.0 update or are they integral to that? It's just that I'm not sure everyone will be able to update to 3.0 straight away (due to the massive skew scaling changes introduced) but may still want those performance improvements in their runtime. Any info on this would be appreciated?

Also, if more info on the 'weird stuff' Unity is/was doing is possible that would be great too, just for our own education to ensure we avoid such things in future.

Many thanks 🙂

Pharan, thanks for your patient reply!
I just find out that the big lag occur in ReadSkeletonData() in SkeletonJson.cs
while deserializing json:

public SkeletonData ReadSkeletonData ( TextReader reader ) {
...
// Causing lag for larger file
var root = Json.Deserailize( reader ) as Dictionary<String, Object>;
...
}

I'll try do this stuff in background to solve problem.
Thank you! 🙂 🙂 🙂

Hi.

Use Binary.

[Unity3D]Unity3D runtime binary format loader problem

It works fine !
Thank you Mitch for the information !
And thanks spine team for binary supporting, too ! 😃 😃 😃

6 أيام لاحقا
ProudLittlePinwheel wrote
Pharan wrote

but in case you're interested, some 20 to 40% mesh-updating performance gains are being worked on. Someone just contributed some changes to the code that works around some weird stuff Unity does.

I was wondering, are the 20-40% mesh updating improvements mentioned going to be merged soon before any big Spine 3.0 update or are they integral to that? It's just that I'm not sure everyone will be able to update to 3.0 straight away (due to the massive skew scaling changes introduced) but may still want those performance improvements in their runtime. Any info on this would be appreciated?

Also, if more info on the 'weird stuff' Unity is/was doing is possible that would be great too, just for our own education to ensure we avoid such things in future.

Many thanks 🙂

So any word on this? Pharan... Anyone... 😢

Ask your mother. (Mitch is your mother.)

Pharan wrote

Ask your mother. (Mitch is your mother.)

Any info Mitch?

Merged last night. didn't forum announce it yet.

unity package is updated too.

(Pharan is your grandmother)

You're welcome, sonny.

It's actually more like 200-300% gain on desktop :p Not so much on mobile, though.

ZimM wrote

It's actually more like 200-300% gain on desktop :p Not so much on mobile, though.

So far it's depended on the contents of my skeletons heh. Either way - thanks 🙂

Yeah it is a tonne faster for me. Awesome stuff!

Just to clarify to late readers, OP's problem was totally different.