Device type detection with Universal app

Hey guys, how can I detect current device type (phone or tablet) app is running when building universal app?

Where do you want to do that?
If in Unity scaripts, than use UNITY_WP_8_1 define. Scripts are compiled twice for each platform separately.

Outside Unity scripts you have two separate apps in the end, should be easy to set this up.

1 Like

I set my project to Windows Store → SDK Universal 8.1
So if I’m getting you right, this code should solve my problem?

{
#if UNITY_WP_8 || UNITY_WP_8_1

//do phone stuff

#elif UNITY_METRO || UNITY_WINRT

//do tablet/destop stuff

#endif
}

You can remove UNITY_WINRT in second condition, as it doesn’t really makes sense, UNITY_WINRT is basically UNITY_METRO || UNITY_WP8. But yes, that code should work.

1 Like