Pre-Processor Directives

The code below is called a preprocessor directive and is only valid if the build is for Android or iOS platform or else the compiler will ignore this code

#if PLATFORM_ANDROID
using UnityEngine.Android;
#elif UNITY_IOS
 using UnityEngine.iOS;
#endif

C# preprocessor directives | Microsoft Docs

I could make 2 separate scripts, 1 for Windows & 1 for Android, but since most of the code is similar instead of repeating myself I can just implement a preprocessor directive. To see what preprocessor directives are in your Unity Project you can go to File/Build Settings/Player Settings/Player/Other Settings/Scripting Define Symbols This doesn't list every available preprocessor directive, such as the PLATFORM_ANDROID shown above

or

Edit/Project Settings/Player/Other Settings/Scripting Define Symbols

Last updated