error: Unsupported texture format - needs to be ARGB32, RGBA32, RGB24 or Alpha8
UnityEngine.Texture2D:EncodeToPNG()
protected IEnumerator PhotoGraphGladiatorCoroutine(Gladiator glad, GameObject obj)
{
string path = Application.persistentDataPath + “/Documents/” + “/pictemp/”;
this.NewPhoto();
this.PutInPosition(obj);
yield return 0;
yield return 2;
byte[ ] byt = PhotoGraphGameObject().EncodeToPNG();
File.WriteAllBytes(path + glad.Name + “.png”, byt);
//glad.Photo = PhotoGraphGameObject();
GameObject.Destroy(obj);
}
protected Texture2D PhotoGraphGameObject()
{
RenderTexture.active = rt;
//RenderTexture.GetTemporary(rt.width, rt.height, TextureFormat.ARGB32, false, false);
Texture2D myTexture2D = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);
myTexture2D.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
myTexture2D.Compress(false);
myTexture2D.Apply();
RenderTexture.active = null;
rt.DiscardContents();
rt.Release();
return myTexture2D;
}
I would like to export the image files.But an error has occurred.