Function 函数错误

Function 函数错误,function,unity3d,unityscript,Function,Unity3d,Unityscript,我尝试了自定义函数: if(Input.GetMouseButtonUp(0)) { AcceptInput = true; targetScript.enabled = false; changeSprite (); } function changeSprite () { //other stuff } 它有一个错误: Assets/Scripts/Button.js(70,1): BCE0070: Definition of 'Button.changeS

我尝试了自定义函数:

if(Input.GetMouseButtonUp(0)) {
    AcceptInput = true;
    targetScript.enabled = false;
    changeSprite ();
}
function changeSprite () {
    //other stuff
}
它有一个错误:

Assets/Scripts/Button.js(70,1): BCE0070: Definition of 'Button.changeSprite()'
depends on 'Button.changeSprite()' whose type could not be resolved because of
a cycle. Explicitly declare the type of either one to break the cycle.

我不明白这个函数有什么问题。有人能帮我吗?

正如错误消息告诉我们的,您可以尝试定义函数的返回类型,在本例中为“void”


我做了你告诉我的事情,并给了我这个错误:Assets/Scripts/Buttons.js(43,27):BCE0101:返回类型“void”不能在生成器上使用。你是说“IEnumerator”吗?您也可以使用“System.Collections.IEnumerable”或“object”。您可以发布整个脚本吗?我怀疑是您发布的代码之外的东西导致了这些问题。我认为这个错误与协同程序有关。见此:
    function changeSprite(): void {
        //other stuff
    }