其他分享
首页 > 其他分享> > 使得图片变为可读的---解决报错Texture '图片名' is not readable, the texture memory can not be accessed from

使得图片变为可读的---解决报错Texture '图片名' is not readable, the texture memory can not be accessed from

作者:互联网

//使得图片变为可读的---解决报错Texture '图片名' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
private Texture2D duplicateTexture(Texture2D source)
{
RenderTexture renderTex = RenderTexture.GetTemporary(
source.width,
source.height,
0,
RenderTextureFormat.Default,
RenderTextureReadWrite.Linear);

Graphics.Blit(source, renderTex);
RenderTexture previous = RenderTexture.active;
RenderTexture.active = renderTex;
Texture2D readableText = new Texture2D(source.width, source.height);
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
readableText.Apply();
RenderTexture.active = previous;
RenderTexture.ReleaseTemporary(renderTex);
return readableText;
}

标签:RenderTexture,readableText,Texture,---,source,报错,Texture2D,renderTex,图片
来源: https://www.cnblogs.com/19940827SR/p/16457500.html