• Runtimes
  • Unity 5 seems to break my runtime [possible Bug?]

  • Modifié
Related Discussions
...

So, I just upgraded my project to Unity 5 and most things survived the upgrading process.. except my precious Spine GameObjects.. 🙁

After reimporting the Skeleton Data Assets, most things seemed to work again but I can't get this one thing to work anymore (which is really important for me):

Submesh Separators

I don't know what broke it but I can't change the Sorting Layer ID of the Submeshes anymore, every time I try to change the setting it won't work at all, reverting my change instantly. Now I don't know whether or not this is a new issue, but this only happened after I switched to the Unity so maybe something broke the runtime? There seems to be a problem in the SkeletonUtility.cs file.

Does anyone else have any problems since switching to v5.0.0 of Unity?

EDIT: So apparently something always causes the Submeshes to be on the Sorting Layer 0 ("Default") and whatever I do, it won't change the sorting layer.

@[supprimé]
That's a different issue. It's not part of the official runtime yet though. (It hasn't been merged yet, and it's not part of the downloadable .unitypackage). But, for what it's worth, that part is fixed and it works in Unity 5. You could use it if you want. 😃

The Submesh separation feature uses SubmeshRenderer components that also has sorting layer stuff in it.
Since the submeshing stuff actually does auto-generation, sorting layer management needs to be handled differently. Let's just wait for Mitch to see how he wants to fix it.

Okay, so I spent the better part of my day hacking the SkeletonUtilitySubmeshRenderer.cs script. Disabling the two lines

cachedRenderer.sortingLayerID = sortingLayerID;
cachedRenderer.sortingOrder = sortingOrder;

lets me modify the Sorting Layers for the Mesh Renderers again.

Unfortunately, it all seems buggy as hell.
Is there any explanation written on how to actually use this Submesh Separator feature in the runtime?
All I could find was 1/2 a forum post by Mitch (who, apparently, wrote it in the first place).

@[supprimé]: Could you enlighten me how to correctly use the Submesh Separators? I really need the feature to put stuff between my animated sprites (it's essential for my gameplay)

EDIT: What seems to be the most troubling is the "random" enabling/disabling of the Parent-Mesh and the Submeshes.
E.g. every time I playtest the Scene, then stop and return to the Scene View, ALL the meshes (parent and submeshes) turn off. The whole Animation "disappears". I can manually turn the renderer components on again but this is basically unusable right now.


Update: I have spent the rest of the day digging into the SkeletonUtilitySubmeshRenderer.cs script. Here's what I found out:

I could (seemingly) solve my Sorting Layer problems by changing the script accessing the SortingLayerName instead of SortingLayerID. Maybe SortingLayerID doesn't work anymore in Unity5?

Anways, by referring to Name instead of ID and changing the script accordingly, I managed to get the Submesh Layering working again.

Another problem showed its ugly head though and I just can't get it to go away:

Whenever I test the scene in Play Mode, stop and go back to Scene View (Editor Mode), my Submeshes disappear!

This seems to happen because the Meshes seem to get RESET but NOT REBUILT. [ExecuteInEditMode] only triggers after I change something in the scene (for example change x-coordinates of the object, set a checkbox etc.) and this succesfully rebuilds the submeshes.

I already tried to make the script rebuild the meshes in Edit Mode but to no avail ( [InitializeOnLoading] doesn't seem to help either)

Yeah, so, there goes my day trying to figure out this thing. Hope I could someone out a bit and I would love to see this fixed.

Thanks for reading! 🙂

@Pharan: Oh, I know that's not merged - I just figured maybe the sorting layer stuff mentioned in that comment is also the issue here 🙂

7 jours plus tard

Any updates on this bug?

Whenever I test the scene in Play Mode, stop and go back to Scene View (Editor Mode), my Submeshes disappear!
They only reappear after I hit Ctrl+S to save the scene or change the scene in any way (e.g. move stuff around)

Does no one else experience this bug?

5 jours plus tard

Yes, I do.
Was going to ask for a solution too

Am going to try to rework submesh system this week in general. Sorry for the trouble.

Mitch a écrit

Am going to try to rework submesh system this week in general. Sorry for the trouble.

Sounds awesome 🙂 What will the changes be?

I'm going to have skeleton mesh renderer generate one mesh per pass instead of submeshes as a "render mode" that can be toggled on. Basically I'm going to do it right this time heh



In hindsight... I'd rather wait until we get someone elses efficiency tweaks into the main runtime officially before I attempt the submesh overhaul. Instead, I've done a patchjob to make Submesh behaviour a bit more consistent. unitypackage and repo updated. Video for example of how to use.

16 jours plus tard
Mitch a écrit

I'm going to have skeleton mesh renderer generate one mesh per pass instead of submeshes as a "render mode" that can be toggled on. Basically I'm going to do it right this time heh


In hindsight... I'd rather wait until we get someone elses efficiency tweaks into the main runtime officially before I attempt the submesh overhaul. Instead, I've done a patchjob to make Submesh behaviour a bit more consistent. unitypackage and repo updated. Video for example of how to use.

Thanks so much, everything works now! The meshes reload! :handshake: :heart:

Yes the internal api changed.

_utilityType = Type.GetType("UnityEditorInternal.InternalEditorUtility, UnityEditor");
_sortingLayerNamesProperty = _utilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
_getSortingLayerUserIdMethod = _utilityType.GetMethod("GetSortingLayerUniqueID", BindingFlags.Static | BindingFlags.NonPublic);

Take a look where these are and compare the difference.

11 jours plus tard

UPDATE: Unfortunately, the meshes still randomly disappear.. initially the updated runtime seemed to have fixed the problem with the meshes not rebuilding after play mode but after about 1h of working on the game, they started to disappear again (after playmode testing). When I hit Save they rebuild but this is still very annoying..

Does anyone know why they are not rebuilding properly?

Sigh.... I have no idea now lol. I did a lot of redundant checking to make sure they got rebuilt... this might have to wait until after we do a big efficiency pass as well as getting the new transform pass nate's working on into the unity runtime... sorry :<

I had this same exact issue and found a workaround for the sorting layers. Basically when I upgraded to Unity 5, all of my layer IDs changed from simple values starting at 1, to crazy long numbers (my Midground layer is now ID #684989807). In the past I used a simple script to help sort some of my non 2D objects like Particle Systems called "Sorting Layer Exposed". I found it online that someone made a long time ago and it's helped me out a lot. Basically you can attach this script to any object, type the layer name in the appropriate field, and you will get the new layer ID. You can then use this ID for your sub-mesh renderers and it should work as expected. Please let me know if you have any questions and I'd be happy to post screens or something.

I am attaching the script so you can take a look and see if it works for you for now.

Best of luck!

@cparki3 for reference: https://github.com/nickgravelyn/UnityToolbag/tree/master/SortingLayer
Note that it's not updated for Unity 5 so the change from simple small ints to full sorting layer UIDs still applies as long as you're using Unity 5.

SkeletonRenderer's inspector code for sorting layers works correctly with Unity 5 though, if you're interested. See here: https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-unity/Assets/spine-unity/Editor/SkeletonRendererInspector.cs#L105

cparki3 a écrit

I had this same exact issue and found a workaround for the sorting layers. Basically when I upgraded to Unity 5, all of my layer IDs changed from simple values starting at 1, to crazy long numbers (my Midground layer is now ID #684989807). In the past I used a simple script to help sort some of my non 2D objects like Particle Systems called "Sorting Layer Exposed". I found it online that someone made a long time ago and it's helped me out a lot. Basically you can attach this script to any object, type the layer name in the appropriate field, and you will get the new layer ID. You can then use this ID for your sub-mesh renderers and it should work as expected. Please let me know if you have any questions and I'd be happy to post screens or something.

I am attaching the script so you can take a look and see if it works for you for now.

Best of luck!

Thanks for the input, I actually used the same script for some time..
The sorting layer bug got sorted out with the latest revision of the runtime, however the bug that prevents meshes from rebuilding after I hit play mode is still there.
The meshes rebuild "more often" now, but they still randomly disappear while I work on the scene.. very annoying, as I'm using the submesh separators for everything basically. 80% of my scene will be invisible from time to time and it's disrupting my workflow..

I took a look at the runtime source code but I know too little about this to fix it by myself..