Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IEnumerator-Waitforseconds-错误(CS1525)_C#_Unity3d - Fatal编程技术网

C# IEnumerator-Waitforseconds-错误(CS1525)

C# IEnumerator-Waitforseconds-错误(CS1525),c#,unity3d,C#,Unity3d,这不起作用,并显示:错误CS1525意外符号“{”您必须为函数定义一个名称 IEnumerator () { // this is were the error is yield return new WaitForSeconds (10); characterdirection.SetInteger ("State", 5); } 这是不正确的代码。接口没有构造函数,很难理解,而你正在尝试做的事情,几乎就像你正在尝试一个非委托。Wa

这不起作用,并显示:错误CS1525意外符号“{”

您必须为函数定义一个名称

IEnumerator () {      // this is were the error is 
        yield return new WaitForSeconds (10);
        characterdirection.SetInteger ("State", 5);
        }

这是不正确的代码。接口没有构造函数,很难理解,而你正在尝试做的事情,几乎就像你正在尝试一个非委托。WaitForSeconds是否返回IEnum?尝试和理解仍然是很好的尝试。是的,这是Unity API的一个yield指令。请参阅;谢谢这有助于这是一个无效的开始还是void更新,它发生在游戏开始时,所以…很抱歉我在编码方面是个新手。另外,你的答案也有同样的问题,即意外符号。在我最后的评论中链接的页面上有一个示例。请查看。另外,我上面提供的代码片段是有效的语法,因此没有更多信息,我无法进一步提供帮助。
IEnumerator WaitAndSetState ()
{    
    yield return new WaitForSeconds (10);
    characterdirection.SetInteger ("State", 5);
}