【发布时间】:2017-05-04 09:38:04
【问题描述】:
你好,我收到了这个错误,我更新了统一 Assets/TCG/Scripts/card.cs(1232,71):错误 CS1622:无法从迭代器返回值。使用 yield return 语句返回一个值,或者使用 yield break 结束迭代
我看了很多次代码,但无法修复它我将添加它这是错误显示的部分。
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();
}
}
}
【问题讨论】:
标签: c# unity3d compiler-errors