-
Notifications
You must be signed in to change notification settings - Fork 41
Description
You may not know it, but when you have two sprites in two different depth, in 2d mode, it would rise the draw call because when the game is being built, the built in atlas generator won't be able to figure it out and put those textures into one atlas.
these days, unity is giving an option to sort sprites inside a single layer by the sort order so.....
in your prefabBuilder.cs, line 140 :
child.localPosition = new Vector3 (spriteInfo.x, spriteInfo.y, oref.z_index); //Z-index helps determine draw order
change it to ==>
child.localPosition = new Vector3 (spriteInfo.x, spriteInfo.y, 0);
and right bellow it, add this line :
renderer.sortingOrder = Mathf.Abs ((int) (oref.z_index * 1000)); //Z-index helps determine draw order
this way, your z_index will be converted to integers and set into the sorting order on sprite renderer and every thing would show properly although the whole sprites are on z = 0 !!!!