Sorting layers not working after build

We’re working on an android game and in it we have a code that should change player’s sorting layer when it comes into contact with specific objects,
it works fine when we play it in Unity,
We view and control the game via UnityRemote and still no problem,
But when we build the project and run it on our phones, sorting layers does not act the way they’re supposed to…!

I want to emphasis that this ONLY happens when we make a build,
We also tried building with Gradle build system, didn’t help…

please if anyone knows anything about this, HELP US…!!!

Hey @515Dastan - I was having the exact same issue with a set of sprites that shared Sorting Layer and were misbehaving on Android Build, while being correctly rendered on Unity Editor and UnityRemote.

The only thing that solved it for me was to set the affected SpriteRenderers’ Sorting Layer to Default, and then back to their real value.
This actually generated changes on the meta files of the prefabs (according to Git), even though apparently the editor was correctly set from the start.

Edit: typo

@sandralc thanks for your reply,
our coding team actually did manage to fix the problem but unfortunately I’m not entirely sure how.
If I’m not mistaken it had to do with changing the layer sorting order as well as the layer itself,
sorry that I cant help more…

Hi,

This happened to me, and after a bit of debugging, the “sorting layer” was incorrect on the build for my player, despite being correct in the editor.

I noticed I had added a new sorting layer just above my player sorting layer, which I think was fine in the editor- but for some reason wasn’t getting updated in the build.

After setting the player’s sorting layer again (set it to default, then back to what its supposed to be), and re-starting Unity, this was fixed.

I’m not sure if just restarting unity would have fixed it though