Access platform's compressed texture size through script? (766042)

Hey all,

I want to grab the compressed file size for textures that Unity displays in the inspector thumbnail. How do I access that? It obviously exists, since Unity is displaying it … I just want to be able to display the same data somewhere else.

We have an automated system for creating asset bundles for our webgl builds from specific folders. I just want to loop through all the textures in those folders, and display their compressed file sizes in one of our editors. It doesn’t matter to me if its not the final size in the build logs (I already have an editor dealing with that)-- I just want that same data that is already being displayed. It would be tremendously helpful to us if I could auto-detect any files over X size, allow us to select them right there, etc etc. Essentially, do exactly what the editor already lets us do on a file-by-file basis, but it would allow me to give us that same data in a much more efficient manner, which actually would allow us to use it to problem-solve.

The only issue is … I can’t figure out where to access that data through script!

You can look in the reference code of the editor to see how unity is getting the data for display

https://github.com/Unity-Technologies/UnityCsReference

You can download the whole archive and start searching for the correct script.

1 Like

Thanks so much, that did the trick. https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Inspector/TextureInspector.cs

1 Like

Sooo much better than having to manually search around :smile:.

1 Like

How did you get access to TextureUtil.GetStorageMemorySizeLong? I get a compile error that says it’s inaccessible due to its protection level.

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