Guye Incognito
Guye Incognito

Reputation: 2830

C# #if directive: Can I write an or statement?

in a Unity3d project I have the following code, so the code that gets compiled will be different depending on what platform you are on.

#if UNITY_IPHONE 
    [DllImport ("__Internal")]   
    #else
    [DllImport ("mylibrary")]
    #endif

I'm wondering if something like this is possible and if so what is the correct syntax

#if UNITY_IPHONE or UNITY_EDITOR_OSX or UNITY_STANDALONE_OSX
    [DllImport ("__Internal")]   
    #else
    [DllImport ("mylibrary")]
    #endif

Upvotes: 0

Views: 3188

Answers (1)

edtheprogrammerguy
edtheprogrammerguy

Reputation: 6039

Use:

#if (UNITY_IPHONE || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
   //other stuff
#else
   //more other stuff
#endif

See the Microsoft documentation for C# preprocessor directives for more information.

Upvotes: 8

Related Questions