产量和WWWForm错误
|
我一直在尝试将代码转换为(页面上的第二个示例):http://unity3d.com/support/documentation/ScriptReference/WWWForm.html
..to Unity3D中的C#:
void Start ()
{
string dataUrl = \"http://www.my-site.com/game/test.php\";
string playName = \"Player 1\";
int score = -1;
// 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
WWW downloadW = new WWW( dataUrl, form );
// Wait until the download is done
yield return downloadW;
if(downloadW.error == null) {
print( \"Error downloading: \" + downloadW.error );
return false;
} else {
// show the highscores
Debug.Log(downloadW.text);
}
}
我收到以下错误:
错误CS1624:“1ѭvoid\”的主体不是迭代器接口类型
阅读后,我尝试将void Start()更改为IEnumerator Start()
..但它表示未声明IEnumerator。
如果我注释掉yield命令,错误就会消失,但是当然不会加载数据。
请有人帮忙吗?
谢谢。
没有找到相关结果
已邀请:
2 个回复
吞睫素
的返回类型,
回调支持
和
作为其返回类型。
一旦返回类型为
,就可以使用
关键字。 大多数回调使您返回return5ѭ,有些则不能:唤醒,更新,LateUpdate,FixedUpdate,OnGUI,OnEnable,OnDisable,OnDestroy。您将需要检查事件回调的文档,以查看它是否不支持作为例程。
辰炔诚薯