Version: 5.4
로드된 에셋 번들(AssetBundles) 추적(Track)
콘텐츠 보호

에셋 번들에 바이너리 데이터 저장 및 로드

첫 단계에는 바이너리 데이터 파일을 “.bytes” 확장자로 저장합니다. Unity는 이 파일을 TextAsset으로 취급합니다. 에셋 번들을 빌드할 때 이 파일을 TextAsset으로 추가할 수 있습니다. 에셋 번들을 애플리케이션에 다운로드하고 TextAsset 오브젝트를 로드한 후에는 TextAsset의 .bytes 프로퍼티를 사용해 바이너리 데이터를 검색해서 가져올 수 있습니다.

string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
    while (!Caching.ready)
        yield return null;

    // 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;
}

로드된 에셋 번들(AssetBundles) 추적(Track)
콘텐츠 보호