zoukankan      html  css  js  c++  java
  • 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;
        }
    
    
    
     
  • 相关阅读:
    Start The Life of Blog
    当你在寻找某件东西时,眼睛是闭着的
    终于升成512m,以此篇纪念一下
    昨天 acm 分组
    FAQ
    VNC
    Telnet
    FTP
    DNS
    Samba
  • 原文地址:https://www.cnblogs.com/SevenPixels/p/10442158.html
Copyright © 2011-2022 走看看