【问题标题】:UnityWebRequestAssetBundle.GetAssetBundle: Why is the download not using the available bandwidth?UnityWebRequestAssetBundle.GetAssetBundle:为什么下载不使用可用带宽?
【发布时间】:2019-07-18 12:35:07
【问题描述】:

我有一个应用程序(平台:Android),我需要从服务器下载资产包。为此,我使用UnityWebRequest 对象:

public IEnumerator GetAssetBundleAsync(string url, Action<AssetBundle> OnSuccess)
    using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url))
        {
            yield return uwr.SendWebRequest();                
            AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
            if (OnSuccess != null)
                OnSuccess(bundle);
        }
}


现在我做了一些性能测试(见图:)。 “In Unity”表示我的应用程序(在 Android 上)进行下载时的数据吞吐量。但是,“在浏览器中”表示直接在我的 Windows 笔记本电脑的浏览器中下载时的吞吐量。两台设备都连接到同一个WIFI。如您所见,后者的最大吞吐量要高得多。

有谁知道为什么从 Unity 应用程序内部下载时吞吐量受到限制以及如何最大化它?

【问题讨论】:

  • @mjwills 我也没有看到图片,所以我不这么认为 :)
  • 我想你错过了发布图片 Benjamin
  • 谢谢你们,它现在就在那里!
  • 很难说没有更多信息。一种可能是浏览器同时发出多个请求?

标签: c# unity3d networking


【解决方案1】:

通过将数据下载为原始字节并将它们作为资产包从内存中加载,我能够绕过以下问题:

public IEnumerator GetAssetBundleByRawBytes(string url, Action<AssetBundle> onSuccess)
{
    using (UnityWebRequest uwr = UnityWebRequest.Get(url))
    {
        yield return uwr.SendWebRequest();
        var bundle = AssetBundle.LoadFromMemory(uwr.downloadHandler.data);
        if (onSuccess != null)
            onSuccess(bundle);
    }
}


这样就可以使用所有可用的带宽。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-15
    • 2013-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多