コガネブログ

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

【Unity】BetterStreamingAssets: file XXXX is where Streaming Assets are put, but is compressed.

概要

BetterStreamingAssets: file XXXX is where Streaming Assets are put, 
but is compressed. 
If this is a App Bundle build, see README for a possible workaround. 
If this file is not a Streaming Asset 
(has been on purpose by hand or by another plug-in), 
implement BetterStreamingAssets.AndroidIsCompressedFileStreamingAsset 
partial method to prevent this message from appearing again. 
  • Better Streaming Assets を使用している Unity プロジェクトにおいて
    Android で BetterStreamingAssets.Initialize(); を実行した時に
    上記のエラーが出る現象に遭遇した
  • Better Streaming Assets がサポートしていないファイルが
    StreamingAssets に存在すると上記のエラーが出る
  • エラーの対処法は README.md に記載されている通り
    partial な AndroidIsCompressedFileStreamingAsset 関数を定義して
    無視するファイルのパスを指定してあげればエラーが出なくなる
using System.Linq;

public static partial class BetterStreamingAssets
{
    private static readonly string[] m_ignoreFilePaths =
    {
        "XXXX",
        "YYYY",
    };

    static partial void AndroidIsCompressedFileStreamingAsset
    ( 
        string path, 
        ref bool result 
    )
    {
        if ( m_ignoreFilePaths.Contains( path ) )
        {
            result = false;
        }
    }
}