Limit to number of cases in switch?

[Please disregard, the problem fixed itself somehow right after I posted. Go figure.]

Hi, me big dum nooby.

I’m messing around with learning animation scripts from a tutorial, where different animations are triggered by pressing various keys. To be slick, I’ve changed all the if-then clauses to script-case. Here’s the code:

        switch (Input.inputString)
        {
        case "1":
            anim.Play ("WAIT01", -1, 0f);
            break;
        case "2":
            anim.Play ("WAIT02", -1, 0f);
            break;
        case "3":
            anim.Play ("WAIT03", -1, 0f);
            break;
        case "4":
            anim.Play ("WAIT04", -1, 0f);
            break;
        case "5":
            anim.Play ("UMATOBI00", -1, 0f);
            break;
        case "6":
            anim.Play ("WAIT04", -1, 0f);
            break;     
        }

Everything worked fine until I added case “6”. No compile errors or anything, it just won’t play. In the above I changed the animation to one of the others to make sure that it wasn’t a problem with the animation setup.

Is there some typo I’m not seeing, or is there a limit to the number of cases you can have in a switch clause?

Thanks for your kind correction.

If you google “.net switch” you will see the following under the first result.

A switch statement can include any number of switch sections, and each section can have one or more case labels (as shown in the string case labels example below). However, no two case labels may contain the same constant value.

I don’t see anything wrong with the syntax of your switch statement above and recommend checking to see if the string provided by Input.inputstring() is what you are expecting. Perhaps it is not matching any of the six values? You could also add a the default case and add some debug output to see if it is hit.

add a default clause, what is likely happening is that none of the cases are true