Distance sorting based on pivot, not sprite's center?

There does not seem to be a way to properly sort different-sized objects along the y axis (or probably any axis) using the current distance sorting implementation. With a custom axis of 0, 1, 0 and sprite pivot set to “bottom” only objects that are the same “height” (y length) are sorted properly.

Here is a GIF of what happens with different-sized objects.

The orange rectangle is sorted properly at its feet because it is the same height as the red square and thus shares the same center. The green square is smaller and does not get sorted at its feet.

Or am I mistaken? Perhaps a setting is wrong?

think in unity 5.5+ they introduced some sort of sprite grouping, system, I cannot remember what it is called, if not you can do this yourself, the following code will be you the position and the width/height, I’m not to sure if this is in worldspace.

mRenderer is the SpriteRenderer

Single mWidth = mRenderer.bounds.size.x;
  Single mHeight = mRenderer.bounds.size.y;
  Single mLeft = Drawing.transform.position.x - (mWidth * 0.5f);
  Single mTop = Drawing.transform.position.y - (mHeight * 0.5f);
  Rect mArea = new Rect(mLeft, mTop, mWidth, mHeight);

then all you need to do is do that to the Red box and adjust the sprite layer index accordingly.

Thanks. Never thought of creating a new rect for objects like this before.

There are several code-based solutions to this and yours may work. But this is specifically about the implementation of Unity’s new axis sorting system. According to official post #37, the sorting is based on the center regardless of the pivot and the Unity 2D team is looking into it.