C## if指令:我可以写一个或声明吗?

Guy*_*ito 0 c# unity-game-engine

在Unity3d项目中,我有以下代码,因此编译的代码将根据您所使用的平台而有所不同.

#if UNITY_IPHONE 
    [DllImport ("__Internal")]   
    #else
    [DllImport ("mylibrary")]
    #endif
Run Code Online (Sandbox Code Playgroud)

我想知道这样的事情是否可能,如果是这样,那么正确的语法是什么

#if UNITY_IPHONE or UNITY_EDITOR_OSX or UNITY_STANDALONE_OSX
    [DllImport ("__Internal")]   
    #else
    [DllImport ("mylibrary")]
    #endif
Run Code Online (Sandbox Code Playgroud)

edt*_*guy 7

使用:

#if (UNITY_IPHONE || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
   //other stuff
#else
   //more other stuff
#endif
Run Code Online (Sandbox Code Playgroud)

http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx