using System.Collections; using System.Collections.Generic; using UnityEngine; namespace UC { public class TextureUtil { public static Texture2D Resize(Texture tex, float downScaleRatio) { RenderTexture temp = RenderTexture.GetTemporary((int)(tex.width / downScaleRatio), (int)(tex.height / downScaleRatio), 0, RenderTextureFormat.ARGB32); Graphics.Blit(tex, temp); RenderTexture current = RenderTexture.active; RenderTexture.active = temp; Texture2D newTex = new Texture2D(temp.width, temp.height, TextureFormat.ARGB32, false); newTex.ReadPixels(new Rect(0, 0, temp.width, temp.height), 0, 0); newTex.Apply(); RenderTexture.active = current; RenderTexture.ReleaseTemporary(temp); return newTex; } } }