From 2d065b675c67dbe21a66373962de478b586e4d7b Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 11 Aug 2021 18:14:50 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B5=84=E6=BA=90=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E3=80=91ui=E8=B4=B4=E5=9B=BE=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=83=8F=E7=B4=A0=E4=B8=BA2=E7=9A=84N?= =?UTF-8?q?=E6=AC=A1=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Editor/OptTools/TextureOptTools.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Editor/OptTools/TextureOptTools.cs b/Assets/Scripts/Editor/OptTools/TextureOptTools.cs index 9728995179..9dfb541849 100644 --- a/Assets/Scripts/Editor/OptTools/TextureOptTools.cs +++ b/Assets/Scripts/Editor/OptTools/TextureOptTools.cs @@ -26,8 +26,10 @@ namespace LJ_OptTools var oHeight = tex.height; if (oWidth <= 0 || oHeight <= 0) return false; - var tarW = (oWidth / 4 + ((oWidth % 4 > 0) ? 1 : 0)) * 4; - var tarH = (oHeight / 4 + ((oHeight % 4 > 0) ? 1 : 0)) * 4; + var tarW = (int)Mathf.Pow(2, Mathf.Ceil(Mathf.Log(oWidth, 2))); + var tarH = (int)Mathf.Pow(2, Mathf.Ceil(Mathf.Log(oHeight, 2))); + //var tarW = (oWidth / 4 + ((oWidth % 4 > 0) ? 1 : 0)) * 4; + //var tarH = (oHeight / 4 + ((oHeight % 4 > 0) ? 1 : 0)) * 4; return oWidth != tarW || oHeight != tarH; } @@ -60,8 +62,11 @@ namespace LJ_OptTools #endregion //图片大小调整为4的整数倍 - var tarW = (oWidth / 4 + ((oWidth % 4 > 0) ? 1 : 0)) * 4; - var tarH = (oHeight / 4 + ((oHeight % 4 > 0) ? 1 : 0)) * 4; + //var tarW = (oWidth / 4 + ((oWidth % 4 > 0) ? 1 : 0)) * 4; + //var tarH = (oHeight / 4 + ((oHeight % 4 > 0) ? 1 : 0)) * 4; + + var tarW = (int) Mathf.Pow(2, Mathf.Ceil(Mathf.Log(oWidth, 2))); + var tarH = (int) Mathf.Pow(2, Mathf.Ceil(Mathf.Log(oHeight, 2))); ret.width = tarW; ret.height = tarH;