我已经使用 Unity 5 和 Unity 2017 构建了应用程序,并且能够使用 Fiddler 或 Charles 成功捕获网络流量。但是,当我使用 IL2CPP 构建 Unity 2018 应用程序(其他应用程序是使用 .Net 构建的)时,该应用程序可以工作(成功发送网络流量),但该应用程序似乎以某种方式绕过了 Fiddler(或 Charles)代理。也就是说,Fiddler 和 Charles 无法显示来自 Unity 2018 IL2CPP 应用程序的网络流量,即使它可以显示来自 Unity 5 和 Unity 2017 应用程序的流量。
请注意,一切都适用于 Unity 5 和 Unity 2017,并且之前已设置 SSL 设置等。此外,我已使用 Fiddler“WinConfig”为 Unity 2018 应用程序启用循环。
我的问题是:我需要做什么才能让 Unity 2018 IL2CPP 应用程序在 Fiddler 或 Charles 中显示流量?
更新: 这是一些示例代码,显示 HttpClient 请求不通过代理,但其他(Unity)网络请求确实通过代理:
public class RequestTest : MonoBehaviour
{
public UnityEngine.UI.Text text;
void Update()
{
if (Input.GetKeyUp(KeyCode.P))
{
StartCoroutine(yieldPing());
}
if (Input.GetKeyUp(KeyCode.O))
{
asyncPing();
}
}
private IEnumerator yieldPing()
{
Debug.Log("This request shows up in Fiddler");
text.text = "UWR in Coroutine";
using (UnityWebRequest uwr = UnityWebRequest.Get("https://www.google.com/"))
{
yield return uwr.SendWebRequest();
}
}
private async void asyncPing()
{
await awaitPing();
}
private async System.Threading.Tasks.Task<bool> awaitPing()
{
Debug.Log("This request also shows up in Fiddler");
UnityWebRequest uwr = UnityWebRequest.Get("https://www.google.com/");
text.text = "UWR in async await";
uwr.SendWebRequest().completed += delegate
{
uwr.Dispose();
};
Debug.Log("This request does NOT show up in Fiddler???");
text.text += "\nHttpClient in async await";
using (System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient())
{
using (System.Net.Http.HttpRequestMessage httpRequest = new System.Net.Http.HttpRequestMessage())
{
httpRequest.RequestUri = new System.Uri("http://www.youtube.com/");
httpRequest.Method = System.Net.Http.HttpMethod.Get;
using (System.Net.Http.HttpResponseMessage httpResponse = await httpClient.SendAsync(httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead))
{
var responseCode = (int)httpResponse.StatusCode;
// We will get a 304 if the content has not been modified
// If there is new, good content, then we will get a 200
return (responseCode == 200);
}
}
}
}
}