Giter Site home page Giter Site logo

Doesn't show texture size in Unity 2022. Не показывает размер текстур в Unity 2022 about unity-resource-checker HOT 5 OPEN

handcircus avatar handcircus commented on June 24, 2024
Doesn't show texture size in Unity 2022. Не показывает размер текстур в Unity 2022

from unity-resource-checker.

Comments (5)

AndreyAs44 avatar AndreyAs44 commented on June 24, 2024 1

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;

from unity-resource-checker.

AndreyAs44 avatar AndreyAs44 commented on June 24, 2024 1

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;
}

from unity-resource-checker.

AndreyAs44 avatar AndreyAs44 commented on June 24, 2024 1

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;
    }

from unity-resource-checker.

builder-main avatar builder-main commented on June 24, 2024

Hi, this seems interesting, however could you try to clarify/synthesize your different posts ?

from unity-resource-checker.

AndreyAs44 avatar AndreyAs44 commented on June 24, 2024

Hi, I don't remember very well anymore, the problem was calculating the size of textures. In this case, the build was for android, ASTC texture formats (automatic most optimal choice of unity). For them, I manually added the counting function (in the existing code) based on my observations and approximate understanding of the documentation. The weight of the sprites practically reflected reality, although there were small discrepancies.

from unity-resource-checker.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.