public void DoUndo(RagePixelCell cell)
    {
        if (cell.GetUndoHistory().Count > 0)
        {
            Texture2D src = atlas.GetTexture("_MainTex") as Texture2D;

            int width    = src.width;
            int height   = src.height;
            int cellXMin = Mathf.FloorToInt(cell.uv.xMin * width);
            int cellYMin = Mathf.FloorToInt(cell.uv.yMin * height);
            int cellXMax = Mathf.FloorToInt(cell.uv.xMax * width);
            int cellYMax = Mathf.FloorToInt(cell.uv.yMax * height);

            Color32[] colors = (Color32[])cell.GetUndoHistory()[cell.undoHistory.Count - 1];
            int       i      = 0;

            for (int y = cellYMin; y < cellYMax; y++)
            {
                for (int x = cellXMin; x < cellXMax; x++)
                {
                    src.SetPixel(x, y, colors[i++]);
                }
            }
            src.Apply();
            cell.GetUndoHistory().RemoveAt(cell.undoHistory.Count - 1);
        }
    }
    public void saveUndo(RagePixelCell cell)
    {
        Texture2D src = atlas.GetTexture("_MainTex") as Texture2D;

        int width    = src.width;
        int height   = src.height;
        int cellXMin = Mathf.FloorToInt(cell.uv.xMin * width);
        int cellYMin = Mathf.FloorToInt(cell.uv.yMin * height);
        int cellXMax = Mathf.FloorToInt(cell.uv.xMax * width);
        int cellYMax = Mathf.FloorToInt(cell.uv.yMax * height);

        Color32[] colors = new Color32[(cellYMax - cellYMin) * (cellXMax - cellXMin)];
        int       i      = 0;

        for (int y = cellYMin; y < cellYMax; y++)
        {
            for (int x = cellXMin; x < cellXMax; x++)
            {
                colors[i++] = src.GetPixel(x, y);
            }
        }
        cell.GetUndoHistory().Add(colors);
    }
    public void DoUndo(RagePixelCell cell)
    {
        if (cell.GetUndoHistory().Count > 0)
        {
            Texture2D src = atlas.GetTexture("_MainTex") as Texture2D;

            int width = src.width;
            int height = src.height;
            int cellXMin = Mathf.FloorToInt(cell.uv.xMin * width);
            int cellYMin = Mathf.FloorToInt(cell.uv.yMin * height);
            int cellXMax = Mathf.FloorToInt(cell.uv.xMax * width);
            int cellYMax = Mathf.FloorToInt(cell.uv.yMax * height);

            Color32[] colors = (Color32[])cell.GetUndoHistory()[cell.undoHistory.Count - 1];
            int i = 0;

            for (int y = cellYMin; y < cellYMax; y++)
            {
                for (int x = cellXMin; x < cellXMax; x++)
                {
                    src.SetPixel(x, y, colors[i++]);
                }
            }
            src.Apply();
            cell.GetUndoHistory().RemoveAt(cell.undoHistory.Count - 1);
        }
    }
    public void saveUndo(RagePixelCell cell)
    {
        Texture2D src = atlas.GetTexture("_MainTex") as Texture2D;

        int width = src.width;
        int height = src.height;
        int cellXMin = Mathf.FloorToInt(cell.uv.xMin * width);
        int cellYMin = Mathf.FloorToInt(cell.uv.yMin * height);
        int cellXMax = Mathf.FloorToInt(cell.uv.xMax * width);
        int cellYMax = Mathf.FloorToInt(cell.uv.yMax * height);

        Color32[] colors = new Color32[(cellYMax - cellYMin) * (cellXMax - cellXMin)];
        int i=0;

        for (int y = cellYMin; y < cellYMax; y++)
        {
            for (int x = cellXMin; x < cellXMax; x++)
            {
                colors[i++] = src.GetPixel(x, y);
            }
        }
        cell.GetUndoHistory().Add(colors);
    }