C# Unity WWW api调用在iOS设备中不起作用
我有一个api,它在某个事件中被调用。api可以在Web平台和编辑器上工作,但不能在iOS设备上工作。以下是我调用api的代码: 我也需要这个api在我的iOS设备上工作。在iOS设备上,当此代码运行时,它会打印日志语句“点击api的时间”,但它从不打印“立即获取响应”日志 请帮帮我,我做错了什么?你能用吗?C# Unity WWW api调用在iOS设备中不起作用,c#,unity3d,C#,Unity3d,我有一个api,它在某个事件中被调用。api可以在Web平台和编辑器上工作,但不能在iOS设备上工作。以下是我调用api的代码: 我也需要这个api在我的iOS设备上工作。在iOS设备上,当此代码运行时,它会打印日志语句“点击api的时间”,但它从不打印“立即获取响应”日志 请帮帮我,我做错了什么?你能用吗? 我用它,效果很好 见示例: // Create a form object for sending high score data to the server var form = new
我用它,效果很好 见示例:
// Create a form object for sending high score data to the server
var form = new WWWForm();
// Assuming the perl script manages high scores for different games
form.AddField( "game", "MyGameName" );
// The name of the player submitting the scores
form.AddField( "playerName", playName );
// The score
form.AddField( "score", score );
// Create a download object
var download = new WWW( someLink, form );
// Wait until the download is done
yield download;
if(download.error) {
print( "Error downloading: " + download.error );
return;
} else {
// show the highscores
Debug.Log(download.text);
}
通常情况下,答案应该不仅仅包括指向工具/库的链接。也许会解释为什么它能解决问题,以及如何使用它来解决问题problem@psubsee2003谢谢你的评论。我添加了示例代码。这在Android、Windows和Windows Mobile中都可以使用,但不幸的是,在iOS上不能使用。Unity上的iOS实现会被破坏吗?我们是否需要在XCode项目的某个地方设置某种特殊标志,以允许苹果设备在互联网上进行通信?
// Create a form object for sending high score data to the server
var form = new WWWForm();
// Assuming the perl script manages high scores for different games
form.AddField( "game", "MyGameName" );
// The name of the player submitting the scores
form.AddField( "playerName", playName );
// The score
form.AddField( "score", score );
// Create a download object
var download = new WWW( someLink, form );
// Wait until the download is done
yield download;
if(download.error) {
print( "Error downloading: " + download.error );
return;
} else {
// show the highscores
Debug.Log(download.text);
}