(MoveNext()并非所有代码路径都返回值)c#
错误:(MoveNext()并非所有代码路径都返回值) 怎么办??? 这真是一个奇怪的错误。。。我不知道是什么 goto也有一个问题,不知道它是如何工作的(MoveNext()并非所有代码路径都返回值)c#,c#,unity3d,C#,Unity3d,错误:(MoveNext()并非所有代码路径都返回值) 怎么办??? 这真是一个奇怪的错误。。。我不知道是什么 goto也有一个问题,不知道它是如何工作的 public override bool MoveNext() { switch (this._state) { case 0: IL_1F:
public override bool MoveNext()
{
switch (this._state)
{
case 0:
IL_1F:
if (!this._self__55.movingPlatform.enabled || (this._self__55.movingPlatform.movementTransfer != MovementTransferOnJump.InitTransfer && this._self__55.movingPlatform.movementTransfer != MovementTransferOnJump.PermaTransfer))
{
goto IL_124;
}
if (this._self__55.movingPlatform.newPlatform)
{
this._platform_54 = this._self__55.movingPlatform.activePlatform;
int arg_12D_0 = this.Yield(2, new WaitForFixedUpdate()) ? 1 : 0;
return arg_12D_0 != 0;
}
goto IL_EF;
case 1:
{
IL_12C:
int arg_12D_0 = 0;
return arg_12D_0 != 0;
}
case 2:
{
int arg_12D_0 = this.Yield(3, new WaitForFixedUpdate()) ? 1 : 0;
return arg_12D_0 != 0;
}
case 3:
if (this._self__55.grounded && this._platform_54 == this._self__55.movingPlatform.activePlatform)
{
int arg_12D_0 = this.Yield(4, 1) ? 1 : 0;
return arg_12D_0 != 0;
}
goto IL_EF;
case 4:
goto IL_EF;
goto IL_1F;
}
IL_EF:
this._self__55.movement.velocity = this._self__55.movement.velocity - this._self__55.movingPlatform.platformVelocity;
IL_124:
this.YieldDefault(1);
}
您已经定义了一个将返回布尔值的函数,但尚未在“switch”语句之后定义“return”语句。因此,如果在最后一行之后设置“return true;”或“return false;”,您的函数将工作。首先,请阅读社区指南,您的问题写得不好,因此需要进行否决投票和结束投票 我希望您继承并没有编写的代码最后缺少一个return语句,即指向标签IL_EF或IL_124的代码路径不返回
IL_EF:
this._self__55.movement.velocity = this._self__55.movement.velocity - this._self__55.movingPlatform.platformVelocity;
IL_124:
this.YieldDefault(1);
return someValue; // you need to return here
哦,哇,我很久没有看到像这样的意大利面代码了!我的建议是永远不要使用
goto
。是的,我知道,告诉我如何更好地修复错误。这看起来像是从反编译器中产生的。经验法则:goto
非常非常糟糕。除非你知道自己在做什么。那只会非常非常糟糕。