The following simple code wants to download an asset bundle asynchronously from a given URL:
private void GetWebContent(String _url) {
Debug.Log("Creating webrequest with URL = " + _url);
_request = WebRequest.Create(_url);
IAsyncResult responseAsyncResult = _request.BeginGetResponse(ResponseCallbackWebRequest, null);
}
private void ResponseCallbackWebRequest(IAsyncResult state) {
Debug.Log("ResponseCallbackWebRequest webrequest with URL = " + _url + "\nstate = " + state.ToString()); // This is the last print that I get in Android
WebResponse response = _request.EndGetResponse(state);
Debug.Log("A"); // this line is never printed out
long contentLength = response.ContentLength;
if (contentLength == -1) {
_error = "Could not get a response from " + url;
Debug.Log(_error);
} else {
Debug.Log("Content Length is " + contentLength);
}
//... extra stuff here
}
I tried both my real asset bundle URL and something fake like 'http://www.google.com' and the result is pretty strange: the code behaves as expected under my Mac and silently fails under Android (no crashes, and the last line printed is the first Log from ResponseCallbackWebRequest).
Is there anything terribly obvious that I'm missing?
↧