protected int CalculateSortingOrder() { Vector2 gridPosition = snappingCamera.WorldToGrid((positionSource != null ? positionSource : transform).position); float t = 1 - MathX.Fract(gridPosition.y); int order = Mathf.FloorToInt(t * (SortingValues - OffsetValues) - (SortingValues - OffsetValues) / 2) + orderOffset; return(order); }