Saving custom key bindings to Player Prefs

Hi,

I read that player prefs could be good for saving custom key bindings but I can’t figure out how to do that. Right now I have a system where the player can choose what keys to use for up, down, left and right and saving that to a dict in the form of a KeyCode.
Next time the player opens the game I want the movement keys to be set to his preferred choice of keys. So I have to save it somehow, is this possible with playerprefs somehow?

You can’t really save out a keycode as a keycode. Instead, you will need to either save it out as a string, or, since enum values also point to ints, it may be better to save out the int value of the KeyCode and then just cast the int back into a KeyCode enum value.

Thanks Brathnann, I didn’t know you could cast to int. This works perfectly!