Platform dependent control schemes

Hi,

I’m fairly new at Unity, but so far quite impressed on how easy a number of things are to achieve. I’ve created a simple game following a tutorial and have now put it on my phone too.

One difference I’ve had to carry out is changing the control scheme so that instead of looking for the keyboard, it looks at the accelerometer in the phone.

This is good and all, but one point is the fact that each time I switch, I’ll have to remember to change the controls over. Is it at all possible to code the scripts so that it has all the possible inputs I will expect to use and then at compile time, the input for the target platform will be used?

Obviously, it’s easy enough to comment and un-comment different controls, just wondering if there is a way that it could be achieved programatically?

I hope that all makes sense. Thanks!

#if UNITY_EDITOR
//keyboard controls here
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
//touch for android devices here
#endif

#if UNITY_IOS && !UNITY_EDITOR
//touch for iOS devices here
#endif

Here you can find more info.