handcircus/Unity-Resource-Checker

Doesn't show texture size in Unity 2022. Не показывает размер текстур в Unity 2022

AndreyAs44 opened this issue · 5 comments

Give feedback if you saw my message!
Most likely, it's in the format that unity chooses by default. That is, if you change it to RGB32, then everything is displayed as it should, and this format does not seem to be supported.

Дайте обратную связь если увидели моё сообщение!
Скорее всего дело в формате, который юнити выбирает по умолчанию. То есть если поменять на RGB32 то всё отображается как надо, а данный формат похоже не поддерживается.

image

case TextureFormat.R8:
return 8;
case TextureFormat.R16:
return 16;
case TextureFormat.BC4:
return 16;
case TextureFormat.BC5:
return 8;
case TextureFormat.BC7:
return 8;
case TextureFormat.RFloat:
return 32;
case TextureFormat.RG16:
return 16;
case TextureFormat.RG32:
return 32;
case TextureFormat.RHalf:
return 16;
case TextureFormat.BC6H:
return 8;
case TextureFormat.RGB48:
return 16;
case TextureFormat.RGFloat:
return 32;
case TextureFormat.RGHalf:
return 16;
case TextureFormat.EAC_R:
return 4;
case TextureFormat.RGBA64:
return 16;
case TextureFormat.EAC_RG:
return 4;
case TextureFormat.RGBAFloat:
return 32;
case TextureFormat.RGBAHalf:
return 16;
case TextureFormat.ETC2_RGB:
return 4;
case TextureFormat.ETC2_RGBA1:
return 4;
case TextureFormat.ETC2_RGBA8:
return 8;
case TextureFormat.EAC_R_SIGNED:
return 4;
case TextureFormat.EAC_RG_SIGNED:
return 8;

int CheckIsBlock(TextureFormat format)
{
switch (format)
{
case TextureFormat.ASTC_HDR_4x4:
return 16;
case TextureFormat.ASTC_HDR_5x5:
return 25;
case TextureFormat.ASTC_HDR_6x6:
return 36;
case TextureFormat.ASTC_HDR_8x8:
return 64;
case TextureFormat.ASTC_HDR_10x10:
return 100;
case TextureFormat.ASTC_HDR_12x12:
return 144;
case TextureFormat.ASTC_4x4:
return 16;
case TextureFormat.ASTC_5x5:
return 25;
case TextureFormat.ASTC_6x6:
return 36;
case TextureFormat.ASTC_8x8:
return 64;
case TextureFormat.ASTC_10x10:
return 100;
case TextureFormat.ASTC_12x12:
return 144;
}

    return 0;
}

int tWidth = tTexture.width;
int tHeight = tTexture.height;
if (tTexture is Texture2D)
{
Texture2D tTex2D = tTexture as Texture2D;

        if (CheckIsBlock(tTex2D.format) == 0)
        {
            int bitsPerPixel = GetBitsPerPixel(tTex2D.format);
            int mipMapCount = tTex2D.mipmapCount;
            int mipLevel = 1;
            int tSize = 0;
            while (mipLevel <= mipMapCount)
            {
                tSize += tWidth * tHeight * bitsPerPixel / 8;
                tWidth = tWidth / 2;
                tHeight = tHeight / 2;
                mipLevel++;
            }
            
            return tSize;
        }
        else
        {
            int bitsPerBlock = CheckIsBlock(tTex2D.format);
            int tSize = tWidth * tHeight / bitsPerBlock * 128 / 8;
            return tSize;
        }
    }
    if (tTexture is Texture2DArray)
    {
        Texture2DArray tTex2D = tTexture as Texture2DArray;

        if (CheckIsBlock(tTex2D.format) == 0)
        {
            int bitsPerPixel = GetBitsPerPixel(tTex2D.format);
            int mipMapCount = 10;
            int mipLevel = 1;
            int tSize = 0;
            while (mipLevel <= mipMapCount)
            {
                tSize += tWidth * tHeight * bitsPerPixel / 8;
                tWidth = tWidth / 2;
                tHeight = tHeight / 2;
                mipLevel++;
            }
            return tSize * ((Texture2DArray)tTex2D).depth;
        }
    }
    else
    {
        Texture2DArray tTex2D = tTexture as Texture2DArray;
        int bitsPerBlock = CheckIsBlock(tTex2D.format);
        int tSize = tWidth * tHeight / bitsPerBlock * 128 / 8;
        return tSize * ((Texture2DArray)tTex2D).depth;
    }