コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Addressable Asset System の AssetBundleRequestOptions でハッシュ値や CRC、ビルドサイズを取得できる

概要

public sealed class Example : IAssetBundleResource
{
    public void Setup( ProvideHandle handle )
    {
        var options = handle.Location.Data as AssetBundleRequestOptions;
        
        // ハッシュ値
        Debug.Log( options.Hash );
        
        // CRC 値
        Debug.Log( options.Crc );
        
        // タイムアウトまでの秒数
        Debug.Log( options.Timeout );
        
        // UnityWebRequest が
        // HTTP / 1.1 チャンク転送エンコード方式を
        // 採用する必要があるかどうか
        Debug.Log( options.ChunkedTransfer );
        
        // 「Redirect Limit Exceeded」システムエラーで停止する前に、
        // この UnityWebRequest がたどるリダイレクトの数
        Debug.Log( options.RedirectLimit );
        
        // リトライ回数
        Debug.Log( options.RetryCount );
        
        // 元のバンドル名(追加されたハッシュは含まれない)
        Debug.Log( options.BundleName );
        
        // バンドルのサイズ
        Debug.Log( options.BundleSize );
        
        // JSON 形式で情報を出力することも可能
        Debug.Log( JsonUtility.ToJson( options, true ) );