Daahrien
Daahrien

Reputation: 10320

Compile code if the platform is not iOS

I know about #if UNITY_IOS to check if the current platform is iOS. But is there a way to check if the platform is NOT iOS?

Something like:

#if NOT UNITY_IOS
//mycode
#endif

I'm currently doing it like this, but it just feels wrong.

#if UNITY_IOS
#else
//my code
#endif

Upvotes: 1

Views: 447

Answers (1)

Programmer
Programmer

Reputation: 125315

If you only want to do something if it is not iOS then use !UNITY_IOS.

#if !UNITY_IOS
//NOT iOS code
#endif

You can add else statement to it if you need to do other things when it is iOS. I don't think you do based on your question. You can learn more about C# Preprocessor Directives here.

Upvotes: 2

Related Questions