Texture转Texture2D
private Texture2D TextureToTexture2D(Texture texture) { Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false); RenderTexture currentRT = RenderTexture.active; RenderTexture renderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 32); Graphics.Blit(texture, renderTexture); RenderTexture.active = renderTexture; texture2D.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0); texture2D.Apply(); RenderTexture.active = currentRT; RenderTexture.ReleaseTemporary(renderTexture); return texture2D; }
private Texture2D RenderTextureToTexture2D(RenderTexture texture) { RenderTexture RT = RenderTexture.active; RenderTexture.active = texture; Texture2D texture2D = new Texture2D(texture.width,texture.height); texture2D.ReadPixels(new Rect(0,0,texture2D.width,texture2D.height),0,0); return texture2D; }
posted on 2019-02-27 10:48 sevenPixels 阅读(1175) 评论(0) 编辑 收藏 举报