title: Texture from Assets folder to Texture2D and the save?
body: <p>I have a Texture in the Assets folder with (Texture Type = Advanced, Read/Write Enabled = true, Max Size = 512, Format = RGB 24 bit). Now I want to read this texture and then copy the pixels into another texture2d and save that.</p>
  
  <pre><code>private Texture2D sourceImg;
  
  ...
  
  Texture2D tex = new Texture2D(512, 512, TextureFormat.RGB24, false);
  tex.SetPixels(sourceImg.GetPixels(0,0,512,512));
  tex.Apply();
  byte[] png = tex.EncodeToPNG();
  File.WriteAllBytes(Application.persistentDataPath + "/Screenshot.png", png);
  </code></pre>
  
  <p>I don't know, why this simple code is not working?</p>
  
  <p>When I add the new tex to a quad with:</p>
  
  <pre><code>quad.renderer.material.mainTexture = tex;
  </code></pre>
  
  <p>It works.</p>