- Home /
Custom conditional enum for controller buttons?
Ok, what i mean is: to increas readability of the code i would like to have a JoystickButton enum with values like Joystick.Start, Joystick.Select and so on instead of the predefined JoystickButton1, JoystickButton2 etc.
Of course my custom enum values would be mapped correctly on the KeyCode corresponding values and then casted in code, but looking at Xbox360Controller page it seems that on different OS the KeyCode values have different meanings, just look at the d-pad buttons that seems not to be mappend on Windows and mapped differently on OsX and Linux.
So, here the question: is it possible to define an enum's values in a conditional way using macros?
Enum JoystickButton {
#if (UNITY_EDITOR_WIN || UNITY_WINRT_10_0)
Start = 7
#elif (UNITY_EDITOR_OSX || UNITY_IOS)
Start = 9
#endif
}
Of course I have to be careful with buttons that seems to be not mapped on every OS, but that said: is it feasable? Would it be usefull? Why yes/no? Have anyone ever tried it?
Your answer
Follow this Question
Related Questions
Another Error - Enum.Parse 1 Answer
Is it possible to omit elements of enum in inspector? 1 Answer
Joystick dpad working But Buttons not working 1 Answer
Convert String into KeyCode (UnityScript) 0 Answers
Switch-case with enum 1 Answer