Zid*_*Lyx 1 c# compiler-errors unity-game-engine
您好,我在更新 unity Assets/TCG/Scripts/card.cs(1232,71) 时收到此错误:错误 CS1622:无法从迭代器返回值。使用yield return语句返回一个值,或者使用yieldbreak结束迭代
我看了很多次代码,但无法修复它,我寻找了修复方案,但我无法理解这一点,所以有人可以帮助我,如果您需要漏洞代码,请告诉我我会添加代码这是错误显示的部分。
IEnumerator PayAdditionalCostAndPlay()
{
if (DiscardCost > 0 && ValidSpell())
{
Player.ActionCancelled = false;
Player.targets.Clear();
Debug.Log("this card has an additional discard cost");
for (int i = 0; i < DiscardCost; i++)
{
Player.NeedTarget = 21; // a card in hand to discard
while (Player.NeedTarget > 0)
{
yield return new WaitForSeconds(0.1f);
}
if (Player.ActionCancelled)
{
Debug.Log("action cancelled");
return false;
}
}
foreach (GameObject target in Player.targets) //discard
{
target.GetComponent<card>().Discard();
}
}
}
Run Code Online (Sandbox Code Playgroud)