Button int cycling not working

We’ve been trying to make an options menu and just ran into a weird problem. MinRes and PlusRes both correspond to buttons that activate them. The idea is to have an int that stores a value for the desired option, and to have SetRes set the right resolution for that int. While working on it we decided to try Debug.Log to check that it was working. We found that it wasn’t. We first tried the button that was supposed to increment. trying it worked until we hit 4, at which point it went to 0 on the next push and then didn’t increment any more(according to the Debug.Log output). After this we tried the decrement button. With gave us 0 (again), 4, 3, 2, 1, 1, 1 and more 1’s after that. We’ve written other functions that work like this but we haven’t tried using debug.log in those functions.

    public void MinRes()
    {
        resValue--;
        if (resValue < 0)
            resValue = 4;
        SetRes (resValue);
    }

    public void PlusRes()
    {
        resValue++;
        if (resValue > 4)
            resValue = 0;
        SetRes (resValue);
    }

    public void SetRes (int resValue)
    {
        Debug.Log (resValue);
    }

going to need to know more about what script is on what gameobject and linked into which button’s onclick event. You might have two version of the script working… in that case, unless resValue is a static value somewhere you’ll have two “resValue” variables in play.

Nah, I think the your code works just as intended. Make sure that collapse is not selected (Screenshot by Lightshot)

This code looks fine. Nothing wrong here

Welp, we feel stupid now. It was collapsed. Thank you very much.