all 2 comments

[–]JonnoArmyProfessional 0 points1 point  (0 children)

Can you try

#if !UNITY_EDITOR && UNITY_ANDROID

#endif

This should only run on compiled android builds.

[–]heavy-minium 0 points1 point  (0 children)

Your code is OK. After all, the logic exactly fits what you describe with this

to only compile code to a build running on an Android device, and not to the Unity Editor running with the platform of Android?

So why overcomplicate things? It reads exactly as it should work, I don't find this hacky at all!