Search Unity

Instructions on how to generate CRC checksums to use with LoadFromCacheOrDownload

Discussion in 'Scripting' started by AN_CH, May 17, 2013.

  1. AN_CH

    AN_CH

    Joined:
    May 17, 2013
    Posts:
    5
    Hi there,

    I'm looking for instructions on how to generate the CRC32 checksums, which are used to verify the downloaded file integrity using WWW.LoadFromCacheOrDownload.

    I want to store a list of CRCs, which are pregenerated at build time and which map to the assetbundle filenames I want to download and have verified. ( Simplified I use CRC32(generated assetbundlefile) ).

    Though the precreated CRCs of the assetbundle files never matches the one that the LoadFromCacheOrDownload - method is expecting.

    Unfortunately, the documentation at http://docs.unity3d.com/Documentation/ScriptReference/WWW.LoadFromCacheOrDownload.html is broken at this point - look at the crc - parameter description, it suddenly stops.


    The only clue I can get out of the documentation that the CRC is calculated for the "uncompressed contents".


    So, can anyone help how to accomplish generating a CRC32, which is the same LoadFromCacheOrDownload expects?
     
  2. ricardo_arango

    ricardo_arango

    Unity Technologies

    Joined:
    Jun 18, 2009
    Posts:
    64
    Hi,

    In Unity 4.1 it isn't possible to get the CRC directly. This is going to be added to the API for a future release, to make it possible to get the CRC value when building the AssetBundle.

    For now the workaround is this:
    - Build your AssetBundle as usual.
    - Try to load it passing a dummy CRC value.
    - The correct CRC value will be printed in the Editor.log : http://docs.unity3d.com/Documentation/Manual/LogFiles.html
    - Replaced the dummy CRC value with the one printed CRC in the log.

    Answers post : http://answers.unity3d.com/questions/359661/generating-loadfromcacheordownload-crc-value.html