Blit() приватный Метод

private Blit ( Texture source, Material mat ) : void
source Texture
mat Material
Результат void
Пример #1
0
        public void CacheAppIcon(string appKey, Texture2D tex, bool force = false)
        {
            RenderTexture rt = new RenderTexture(32, 32, 24, RenderTextureFormat.ARGB32);

            Graphics.Blit(tex, rt);

            Directory.CreateDirectory(iconCacheFolder);

            string path = Path.Combine(iconCacheFolder, appKey + ".png");

            DumpRenderTexture(rt, path);
        }
Пример #2
0
 public static void TrySaveToPNG(this Texture texture, string filePath)
 {
     try
     {
         RenderTexture tmp = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);
         Graphics.Blit(texture, tmp);
         RenderTexture previous = RenderTexture.active;
         RenderTexture.active = tmp;
         Texture2D myTexture2D = new Texture2D(texture.width, texture.height);
         myTexture2D.ReadPixels(new Rect(0, 0, tmp.width, tmp.height), 0, 0);
         myTexture2D.Apply();
         RenderTexture.active = previous;
         RenderTexture.ReleaseTemporary(tmp);
         var bytes = ImageConversion.EncodeToPNG(myTexture2D);
         File.WriteAllBytes(filePath, bytes);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }