我一直在寻找我的问题的答案。我试图使用Unity中的WWW(URL)和Javascript从我的网络玩家游戏中将分数发送到我的服务器。我已经尝试了几种解决方案,但我不确定我是否已经完成了任何一项,因为对它们没有任何好的解释。这是我现在的代码
var url = "http://www.domain.com/folder/page.php";
function start(){
var scoreForm = new WWWForm();
scoreForm.AddField("score", gamecontroller.score);
// Sending request:
var httpResponse = new WWW(url, scoreForm);
// Waiting for response:
yield httpResponse;
var form = new WWWForm();
form.AddField( "score", gamecontroller.score );
var www = new WWW( url, form );
// wait for request to complete
yield www;
// and check for errors
if (www.error == null)
{
// request completed!
} else {
// something wrong!
Debug.Log("WWW Error: "+ www.error);
}
}