C# UnityWebRequest已发送错误
每当我试图将unity中的数据发送到我的php文件时,这两个错误就会不断出现。我尝试了所有我能找到的关于“curl error 51”的修复方法,所以我假设主要问题是第二个错误C# UnityWebRequest已发送错误,c#,php,unity3d,C#,Php,Unity3d,每当我试图将unity中的数据发送到我的php文件时,这两个错误就会不断出现。我尝试了所有我能找到的关于“curl error 51”的修复方法,所以我假设主要问题是第二个错误 Curl error 51: Cert verify failed: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED 我已尝试查找此错误,但找不到任何答案 InvalidOperationException: UnityWebRequest has already been sent; can
Curl error 51: Cert verify failed: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED
我已尝试查找此错误,但找不到任何答案
InvalidOperationException: UnityWebRequest has already been sent; cannot begin sending the request again
UnityEngine.Networking.UnityWebRequest.SendWebRequest () (at <2424cac47b134bcb9980d5fdf8ea4441>:0)
AddScore+<Register>d__5.MoveNext () (at Assets/Scripts/AddScore.cs:30)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <e8645a79b0794e0e9a2b5bbff081b88a>:0)
正如错误消息所说,WebRequest太多了 而不是
IEnumerator Register()
{
WWWForm form = new WWWForm();
form.AddField("name", "nameField.text");
using (UnityWebRequest www = UnityWebRequest.Post("https://localhost/sqlconnect/addscore.php", form))
{
yield return www.SendWebRequest();
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
UnityEngine.SceneManagement.SceneManager.LoadScene(0);
}
使用
返回www.SendWebRequest;在代码中出现两次。正如错误所说,您只需要一个。我假设UNITYTLS_X509; Verify_FLAG_NOT_TRUSTED错误是因为您正在使用https和自签名证书或其他导致其不受信任的内容。也许可以先尝试http,将问题缩小到您的代码或配置;{yield return www.SendWebRequest;然后您需要一个https证书处理程序!请参阅这是否回答了您的问题?;这看起来很像是一个基于打字错误/意外事件的问题,因此脱离主题,因为它在将来不会真正帮助其他人
IEnumerator Register()
{
WWWForm form = new WWWForm();
form.AddField("name", "nameField.text");
using (UnityWebRequest www = UnityWebRequest.Post("https://localhost/sqlconnect/addscore.php", form))
{
yield return www.SendWebRequest();
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
UnityEngine.SceneManagement.SceneManager.LoadScene(0);
}
IEnumerator Register()
{
WWWForm form = new WWWForm();
form.AddField("name", "nameField.text");
using (UnityWebRequest www = UnityWebRequest.Post("https://localhost/sqlconnect/addscore.php", form))
{
yield return www.SendWebRequest();
{
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
UnityEngine.SceneManagement.SceneManager.LoadScene(0);
}