public static Sprite DrawSpriteBorders(Sprite spr, int z, InmediateWallNeighbors neighbors, bool isCropped)
        {
            Texture2D tex = new Texture2D(spr.texture.width, spr.texture.height, spr.texture.format, Settings.mipmapEnabled)
            {
                filterMode = Settings.filterMode,
                wrapMode   = Settings.wrapMode
            };

            Graphics.CopyTexture(spr.texture, tex);

            if (Settings.DRAW_WALL_BORDERS)
            {
                DrawBorders(tex, z, neighbors);
            }
            else
            {
                CutCorners(tex, z, neighbors);
            }

            if (isCropped)
            {
                Crop(tex, cropLength, z);
            }

            tex.Apply();

            Sprite end = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Settings.wallPivot, Settings.PPU);

            return(end);
        }
        private static void CutCorners(Texture2D tex, int z, InmediateWallNeighbors neighbors)
        {
            // Delete border color pixel
            tex.SetPixel(0, 0, Color.clear);

            if (z == 1)
            {
                FlipTex(tex);
                neighbors.FlipSideNeighbors();
            }

            if (!neighbors.TopLeft.IsEmpty())
            {
                DrawIsoLine(tex, Color.clear, BackTop, new Vector2Int(BackTop.x - 1, BackTop.y));

                if (neighbors.Top.IsEmpty() && neighbors.TopRight.IsEmpty())
                {
                    Color topColor = tex.GetPixel(RightTop.x - 2, RightTop.y - 1);
                    DrawIsoLine(tex, topColor, new Vector2Int(RightTop.x, RightTop.y + 1), new Vector2Int(RightTop.x - 1, RightTop.y + 1));
                }
            }

            if (!neighbors.TopRight.IsEmpty())
            {
                DrawVerticalLine(tex, Color.clear, RightTop, RightBottom);
                DrawVerticalLine(tex, Color.clear, new Vector2Int(RightTop.x - 1, RightTop.y), new Vector2Int(RightBottom.x - 1, RightBottom.y));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(RightTop.x - 2, RightTop.y + 1), new Vector2Int(RightBottom.x - 2, RightBottom.y - 1));

                Color topColor = tex.GetPixel(RightTop.x - 3, RightTop.y + 1);
                DrawVerticalLine(tex, topColor, new Vector2Int(RightTop.x - 3, RightTop.y + 2), new Vector2Int(RightTop.x - 3, RightTop.y + 2));
            }

            if (!neighbors.BottomLeft.IsEmpty())
            {
                DrawVerticalLine(tex, Color.clear, LeftTop, LeftBottom);
                DrawVerticalLine(tex, Color.clear, new Vector2Int(LeftTop.x + 1, LeftTop.y), new Vector2Int(LeftBottom.x + 1, LeftBottom.y));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(LeftTop.x + 2, LeftTop.y + 1), new Vector2Int(LeftBottom.x + 2, LeftBottom.y - 1));

                Color topColor = tex.GetPixel(LeftTop.x + 4, LeftTop.y - 2);
                DrawIsoLine(tex, topColor, new Vector2Int(LeftTop.x + 3, LeftTop.y - 2), new Vector2Int(LeftTop.x + 3, LeftTop.y - 2));

                for (int yi = LeftBottom.y - 3; yi <= LeftTop.y - 3; yi++)
                {
                    DrawIsoLine(tex, tex.GetPixel(LeftTop.x + 4, yi), new Vector2Int(LeftTop.x + 3, yi), new Vector2Int(LeftTop.x + 3, yi));
                }
            }

            if (z == 1)
            {
                FlipTex(tex);
                neighbors.FlipSideNeighbors();
            }
        }
        private static void DrawBorders(Texture2D tex, int z, InmediateWallNeighbors neighbors)
        {
            Color borderColor = tex.GetPixel(0, 0);

            tex.SetPixel(0, 0, Color.clear);

            if (z == 1)
            {
                FlipTex(tex);
                neighbors.FlipSideNeighbors();
            }

            DrawIsoLine(tex, borderColor, FrontBottom, RightBottom);
            DrawIsoLine(tex, borderColor, FrontTop, RightTop);
            DrawIsoLine(tex, borderColor, new Vector2Int(LeftTop.x + 2, LeftTop.y + 1), new Vector2Int(BackTop.x - 2, BackTop.y - 1));

            if (neighbors.Bottom.IsEmpty())
            {
                if (neighbors.BottomLeft.IsEmpty())
                {
                    DrawVerticalLine(tex, borderColor, LeftBottom, LeftTop);
                    DrawVerticalLine(tex, borderColor, FrontBottom, FrontTop);

                    if (neighbors.BottomRight.IsEmpty())
                    {
                        DrawIsoLine(tex, borderColor, new Vector2Int(FrontTop.x + 1, FrontTop.y), LeftTop);
                        DrawIsoLine(tex, borderColor, new Vector2Int(FrontBottom.x + 1, FrontBottom.y), LeftBottom);
                    }
                }
            }

            if (neighbors.BottomLeft.IsEmpty() && neighbors.BottomRight.IsEmpty() == false)
            {
                DrawIsoLine(tex, borderColor, LeftTop, new Vector2Int(LeftTop.x + 1, LeftTop.y));
            }

            if (neighbors.Top.IsEmpty())
            {
                DrawVerticalLine(tex, borderColor, RightBottom, RightTop);
            }

            if (neighbors.TopLeft.IsEmpty())
            {
                DrawIsoLine(tex, borderColor, BackTop, new Vector2Int(BackTop.x - 1, BackTop.y));
            }
            else
            {
                DrawIsoLine(tex, Color.clear, new Vector2Int(BackTop.x - 1, BackTop.y), BackTop);
            }

            if (neighbors.Top.IsEmpty() && neighbors.TopLeft.IsEmpty() && neighbors.TopRight.IsEmpty())
            {
                DrawIsoLine(tex, borderColor, new Vector2Int(BackTop.x + 1, BackTop.y - 1), new Vector2Int(BackTop.x + 2, BackTop.y - 1));
            }

            if (neighbors.TopRight.IsEmpty() == false && z == 0)
            {
                DrawVerticalLine(tex, Color.clear, new Vector2Int(tex.width - 1, 0), new Vector2Int(tex.width - 1, tex.height));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(tex.width - 2, 0), new Vector2Int(tex.width - 2, tex.height));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(tex.width - 3, 0), new Vector2Int(tex.width - 3, tex.height));
                DrawVerticalLine(tex, borderColor, new Vector2Int(RightTop.x - 3, RightTop.y - 2), new Vector2Int(RightBottom.x - 3, RightBottom.y));

                if (neighbors.Top.IsEmpty() && neighbors.TopLeft.IsEmpty())
                {
                    DrawIsoLine(tex, borderColor, new Vector2Int(BackTop.x + 1, BackTop.y), new Vector2Int(BackTop.x + 2, BackTop.y));
                }
            }

            if (neighbors.TopLeft.IsEmpty() == false && neighbors.Top.IsEmpty() && neighbors.TopRight.IsEmpty())
            {
                tex.SetPixel(RightTop.x - 1, RightTop.y + 1, tex.GetPixel(RightTop.x - 2, RightTop.y + 1));
            }

            if (neighbors.BottomLeft.IsEmpty() == false)
            {
                DrawVerticalLine(tex, Color.clear, new Vector2Int(0, 0), new Vector2Int(0, tex.height));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(1, 0), new Vector2Int(1, tex.height));
                DrawVerticalLine(tex, Color.clear, new Vector2Int(2, 0), new Vector2Int(2, tex.height));

                if (neighbors.Bottom.IsEmpty() && neighbors.BottomRight.IsEmpty())
                {
                    int x = FrontTop.x - 1;
                    tex.SetPixel(x, FrontTop.y, tex.GetPixel(x, FrontTop.y + 1));

                    if (z == 0)
                    {
                        DrawVerticalLine(tex, borderColor, new Vector2Int(x, FrontTop.y - 1), new Vector2Int(x, FrontBottom.y));
                    }
                    else
                    {
                        for (int y = FrontBottom.y + 1; y < FrontTop.y; y++)
                        {
                            tex.SetPixel(x, y, tex.GetPixel(x + 1, y + 1));
                        }
                        tex.SetPixel(x, FrontBottom.y, borderColor);
                    }
                }
            }

            if (z == 1)
            {
                FlipTex(tex);
                neighbors.FlipSideNeighbors();
            }
        }