Unity Render à Texture2D

public static void ExportTexture2D(int w, int h) {
  Texture2D outputTexture = new Texture2D(w, h);
  Rect rect = new Rect(0, 0, outputTexture.width, outputTexture.height);
  
  RenderTexture rt = RenderTexture.GetTemporary(texture.width, texture.height);
  RenderTexture.active = rt;
  
  outputTexture.ReadPixels(rect, 0, 0);
  outputTexture.Apply(false); // do not apply mipmaps
  outputTexture.Compress(true); // compress with high quality
  
  RenderTexture.active = null;
  RenderTexture.ReleaseTemporary(rt);
}
Clever Cow