How can I ask at the script level (C #) in Unity on which platform the game is running?

0

I would like to develop a multiplatform game in Unity mainly for Windows and Android. The problem is that in Android I would put controls using UI to allow the user to interact with the game in the absence of the default controls that my Windows game uses. I can do it, I would like these controls made with UI only appear when the game is running on Android and not in Windows, so if you can ask what device is running you could know if it is running on Android and then show the controls and otherwise not doing it.

    
asked by Marok 17.09.2018 в 15:07
source

1 answer

1

You could evaluate using

Application.platform

to know the platform where it is running, you will see in the example use

if (Application.platform == RuntimePlatform.WindowsPlayer)

Another alternative is to define conditional compilation code according to the platform

Platform dependent compilation

something like being

#if UNITY_ANDROIDR
   //codigo
#endif

then when you compile it will generate specific code

    
answered by 17.09.2018 / 21:47
source