• Unity
  • Skeleton render Separator and material problem

Related Discussions
...

Hi,

I'm trying to use the skeleton render separator in order to put an object visually between two parts of a spine object.

So I followed this tutorial : https://github.com/pharan/spine-unity-docs/blob/master/SkeletonRenderSeparator.md

But when I do it , there is a problem : on the skeleton part renderers some materials are not linked. If I link it by hand an press play, it's set to none again and I get this error :

NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.MeshGeneration.ArraysSubmeshSetMeshGenerator+SmartMesh.StructureDoesntMatch (Spine.ExposedList`1 attachments, Spine.ExposedList`1 instructions) (at Assets/Plugins/Spine/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs:181)
Spine.Unity.MeshGeneration.ArraysSubmeshSetMeshGenerator.GenerateMesh (Spine.ExposedList`1 instructions, Int32 startSubmesh, Int32 endSubmesh) (at Assets/Plugins/Spine/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs:109)

Which is a null material problem. The animations does not work and the spine object is broken.
Then if I look to the main mesh renderer there is now 2 materials with one set to null, and I cannot change material count or value because it's automatically reset.

Even when I just Disable/Re-Enable the Skeleton Render Separator I got this error and cannot set the material count to 1.

Am I missing something? Thanks in advance

Did you update your spine-unity recently? There was a bug related to this that was recently fixed (a couple of weeks ago).

If not, can you send your project to unity@esotericsoftware.com and describe your setup? (ie, which slot is the separator, what animation to play, etc...)

Ok I'm updating. It's a painfull process (update all editors, merge manually the changed code, re export EVERY skeletons (not compatible with 3.2 editor)). I'll try again the the skeleton render separator when everything will be done.

You should be able to update just a small part, I think. Let me look for that specific fix.


03 Aug 2016 7:11 pm


Try these changes from July 11:
[spine-unity] SkeletonRenderer fix null 1st material. · EsotericSoftware/spine-runtimes@2fdd820 · GitHub
Particularly, look at new lines 313 and 314. The resolution order/parentheses make all a difference.

The rest of the changes are just formatting, so, that's up to you if you want to apply them too.
Obviously, those won't do anything functionally different.

Ok so after the update it works. But it seems that having more than 2 skeleton part renderers does not work. When I add others, there is only the first and second one that generate meshes. (the first have all bones but the second part ones. The third an other are just empty). It's not a problem in my particular case but I wonder if there is some rule to make it work with 3+ parts?

No, it should work fine with any number of part renderers.

I think there may be cases of separators immediately next to each other in the list I haven't caught.
Can you share how your separator slots are arranged?

Slot draw order aren't arranged in a tree and are independent of the arrangment of the bones. It's a list.

In Spine editor , the slot are linked to bones.
skeleton renderer separator component (in unity) use slots (spine slots). The picture show at which bones the slot are related to.
The separator needs to be related to bone, or how it decide which mesh to build?

In the skeleton renderer separator component there is 2 slots (Separator slot 1/2 like the picture) and 3 part renderers. Only part renderer 1 and 2 work. (the mesh is only separated in 2 part).
The problem is not the draw order but the mesh separation;

Mesh separation depends on draw order/slot list (see, Skeleton.slots which is the order SkeletonRenderer uses.) and doesn't care about the bones.
The bones are only relevant when the vertices need to be positioned, which each attachment type process on their own internally. They are not relevant in the sorting and separation process.

I have tested separating the Spineboy render into 7 parts and all parts work correctly.
So I need to know what's special about your setup to figure out your problem. This does not involve bones.

The arranged list is the same list that appears when you choose the separator slot.
It is also the same list you see in Spine editor Draw Order node.

Ok so I send a exemple where it does not work for me.

The needed separation are for slots HookUL and HookOL
Objects need to be between the body and the pliers. (each plier need to be independant)

Then in unity it's setuped like this :

There is then 3 separator objects created (named 0,1,2)

But the object 2 is empty :

The object 0 mesh have the full body and one plier, the object 1 have the other plier, the object 2 is empty.

One case where the last mesh may be empty is if one of your separators is the first item in the slot list.

Choosing a separator slot means that will be the first slot for a new set. If it's the first, it means "make this first slot be the first slot of the first set".
The inspector doesn't warn against this, but it would mean you need one less renderer than the inspector thinks you need. At runtime, it would leave the last renderer empty, which is expected, and harmless.

This seems to be your case. HookOL is the first slot.
Maybe you wanted to set Tail01 as the separator instead?

If you want it to be unambiguous, you should create empty slots in Spine editor to use as separators, and use those in Spine-Unity. But as long as you understand what's going on, not having the empty slots is fine too.

Ok so I tried both solution :

  • Using Tail01 instead of hookUL or hookOL : it change nothing. Actually, if I set 1 or 2 separators, in every possible combination, the result is the same. (Yes I clean the part renderers for each test).

-Adding 3 fake slots, one before each real slot. Then in unity, trying every possible combination : still does not work.

It really seems "magic" how the mesh is constructed and not related to choosed separator 🙁

Did you update to Unity 5.4?
I also noticed a new behavior in their editor that causes the separation to not update unless you enter and exit play mode.
This did not seem to be a problem in 5.3.

But I replicated your skeleton (3 slots), and used two separators: the 2nd and 3rd slot. It works correctly.
You end up with 3 separate renders.

No I Use 5.3.5f1. Anyway I tested it in play mode, still does not work.

The renders gameObjects are created but have you checked if the mesh is really separated in 3 parts?
Can you send a screenShot showing the 3 part renderers? It's really strange that it works with the same data.

Edit :
Oh actually it works ! It worked as you said after starting play mode AND exiting the game. Then after you re-start play mode it will continue to work.

thanks for your time.

I'm currently investigating why it's not updating correctly in edit mode.
Hopefully it is fixable.