我在向Unity添加代码时遇到了反复出现的问题。每次我添加代码时,即使删除代码,我在添加代码后也无法工作。例如:
新代码
if(switchSidesToggle.isOn)
{
if (team1Button.position == leftButtonPos)
{
team1Button.position = leftButtonPos;
team1SetPos.position = leftSetPos;
team1TimeoutTrans.position = leftTimeoutPos;
team2Button.position = rightButtonPos;
team2SetPos.position = rightSetPos;
team2TimeoutTrans.position = rightTimeoutPos;
}
else
{
team1Button.position = leftButtonPos;
team1TimeoutTrans.position = leftTimeoutPos;
team1SetPos.position = leftSetPos;
team2Button.position = rightButtonPos;
team2TimeoutTrans.position = rightTimeoutPos;
team2SetPos.position = rightSetPos;
}
}
旧代码
if(switchSidesToggle.isOn)
{
if (team1Button.position == leftButtonPos)
{
team1Button.position = leftButtonPos;
team1TimeoutTrans.position = leftTimeoutPos;
team2Button.position = rightButtonPos;
team2TimeoutTrans.position = rightTimeoutPos;
}
else
{
team1Button.position = leftButtonPos;
team1TimeoutTrans.position = leftTimeoutPos;
team2Button.position = rightButtonPos;
team2TimeoutTrans.position = rightTimeoutPos;
}
}
更改的内容是team1SetPos
和team2SetPos
行。一旦我将这些添加到我的代码中,它就开始根本不切换侧面。有人能帮助我吗?