ロードされたアセットバンドルのトラッキング方法
コンテンツの保護

アセットバンドルでのバイナリデータの格納とロード

最初のステップはバイナリデータを“.bytes” 拡張子で保存することです。Unityは TextAsset (テキストアセット)としてファイルを取り扱います。テキストアセットの場合,ファイルはAssetBundle(アセットバンドル)をビルドするときにincludeすることが出来ます。アセットバンドルをアプリケーションにダウンロードして,テキストアセット オブジェクトをロードした後,テキストアセットの.bytes プロパティを使用してバイナリデータを取得することが出来ます。

string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
    // Start a download of the given URL
    WWW www = WWW.LoadFromCacheOrDownload (url, 1);

    // Wait for download to complete
    yield return www;

    // Load and retrieve the AssetBundle
    AssetBundle bundle = www.assetBundle;

    // Load the TextAsset object
    TextAsset txt = bundle.Load("myBinaryAsText", typeof(TextAsset)) as TextAsset;

    // Retrieve the binary data as an array of bytes
    byte[] bytes = txt.bytes;
}

ロードされたアセットバンドルのトラッキング方法
コンテンツの保護