Search Unity

Access platform's compressed texture size through script?

Discussion in 'Editor & General Support' started by DGordon, Nov 18, 2019.

  1. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    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!
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    DGordon likes this.
  3. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    fffMalzbier likes this.
  4. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Sooo much better than having to manually search around :D.

    texture_sizes.PNG
     
    fffMalzbier likes this.
  5. lolun

    lolun

    Joined:
    Nov 25, 2014
    Posts:
    16
    How did you get access to TextureUtil.GetStorageMemorySizeLong? I get a compile error that says it's inaccessible due to its protection level.
     
  6. somemail87

    somemail87

    Joined:
    Oct 2, 2018
    Posts:
    2