Get compressed texture size in Editor

Hello, I’m trying to find out how to get this circled value through script. I’m trying to create a tool that will let you see the size of a selection, not just one texture at a time.
4387042--398359--2019-04-03 14_31_10.png

Have tried a couple of things, using the AssetDatabase to try and load the asset at the path and try to dig into it’s metadata even in the library.

Using Profiler.GetRuntimeMemorySizeLong(obj) seems to be it’s size uncompressed.

Any pointers where I should be looking for this sort of information?.

Thanks!

The Inspector preview uses the following code:

EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(t));

Sadly the TextureUtil class is editor intanal. You probable can access it via reflections.

You can get the editor source code for Reference purposes so you can see what unity is using in this cases:

1 Like

Thanks for the info - I’d forgotten we can browse the editor source!
Cheers

https://www.programmersought.com/article/98995138692/

1 Like