Configurable Cursors error

Hey, I have seemed to have hit a error and have no idea why or how its come about. I have gone over the same video around 30 times and rechecked everything but still ahve the error
Please see attacched picture

‘PlayerController.GetCursorMapping(PlayerController.CursorType)’: not all code paths return a value [Assembly-CSharp]

Can anyone help me to fix this im using unity 2019.4.15f1

thanks in advance

1 Like

Hi!

See the comment in the code below to fix your error.

    private CursorMapping GetCursorMapping(CursorType type)
        {
            foreach (CursorMapping mapping in cursorMappings)
            {
                if (mapping.type == type)
                {
                    return mapping;
                }
            }
            return cursorMappings[0]; //This return goes outside the foreach loop.
        }

"not all code paths return a value " When dealing with this kind of errors check your “returns”, you must have at least one outside the “if” statements and loops.

2 Likes

Thank you so much i didnt even see i placed that in the wrong area I rechecked over and over and yeah
thank you again

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms