|
第一步是要救你的二进制数据文件的字节扩展。”。统一将此文件作为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;
}
|
|