Graphics.CopyTexture no longer works in 2019.3.7f1

Our project needed to upgrade to 2019.3.7f1 for an SDK upgrade on a proprietary console.

This is the code we’ve been using forever (5.x until 2019.1.0f2)

public Texture2D StampPatch(Texture2D origTexture, float x1, float y1, float x2, float y2)
    {   
        int w = (int)(x2 - x1);
        int h = (int)(y2 - y1);

        Texture2D tex = new Texture2D(w, h, TextureFormat.RGBA32, origTexture.mipmapCount, false);

       tex.anisoLevel = 0;
       tex.filterMode = FilterMode.Point;
       tex.wrapModeV = TextureWrapMode.Repeat;
       tex.wrapModeU = TextureWrapMode.Repeat;
       tex.Apply();

        Graphics.CopyTexture(origTexture, 0, 0, (int)x1, (int)y1, w, h, tex, 0, 0, 0, 0);  
        return tex;
    }

It throws this error:

  • Graphics.CopyTexture called with region not fitting in destination element (dstX 0, dstY 0, srcWidth 24, srcHeight 24, dstMip 0 → dstWidth 24, dstHeight 24)
  • UnityEngine.Graphics:CopyTexture(Texture, Int32, Int32, Int32, Int32, Int32, Int32, Texture, Int32, Int32, Int32, Int32)

Any help would be greatly appreciated.

Are you using the Master Texture Limit settings?

What is the format or the original texture?

I can’t see anything obviously wrong in our code around this, and also I can’t see anything wrong with your code based on the info provided so far.

Almost certainly we will need a bug report with minimal repro project to get to the bottom of this.