向函数添加代码会使函数停止工作(统一)

时间:2017-05-24 22:37:46

标签: c# debugging unity3d

我在向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;
    }
}

更改的内容是team1SetPosteam2SetPos行。一旦我将这些添加到我的代码中,它就开始根本不切换侧面。有人能帮助我吗?

0 个答案:

没有答案