Sprite Renderer Sorting Layers
I have a simple script that sorts the sprite renderer layers after their z position. The only problem is that when there are multiple sprites on the same z axis the layering flips out because they get the same sorting layer. Here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; [ExecuteInEditMode] public class SpriteSorting : MonoBehaviour { [SerializeField] float spriteTransform; [SerializeField] int spriteOrder; Vector3 spritePos; GameObject cam; void Update() { //global transform position determines sorting layer: spriteTransform = this.transform.position.z; spriteOrder = (int)spriteTransform; this.gameObject.GetComponent<SpriteRenderer>().sortingOrder = spriteOrder; } }
Answer by Kopp_Te · Jul 24, 2021 at 10:38 AM
I solved this by turning all my sprites into 3d objects through magica voxel (importing my aseprite palette because magica voxels palette is quite limited). Then i fixed my lighting so it looked like 2d sprites.
Your answer
![](https://koobas.hobune.stream/wayback/20220613040724im_/https://answers.unity.com/themes/thub/images/avi.jpg)