When we use Unity to connect 91,XY Assistant and so on SDK. We need to use [DllImport ("__internal")] to declare a C + + method call.
Different SDKs will always have different methods. I am used to writing XYSDK class, BAIDU91SDK class inside the various [DllImport ("__internal")] declared method
The problem is, if we release the XY SDK, and the method of the SDK is not placed in the Xcode project. So the compilation does not pass. We need to put the method of the C + + package into the project.
We can use pre-processing commands (to choose to compile some code) so that we do not need to publish XY, but also to put the method of the C + + encapsulated in Xcode compiled
#defineBaidusdk//#define XYSDK//If we need to send that version of the SDK, we'll comment out the other # define.usingUnityengine;usingSystem.Collections; baidu91sdk{#if(BAIDUSDK)[DllImport ("__internal")] Private Static extern voidbuy props ();#endif}xysdk{#if(XYSDK)[DllImport ("__internal")] Private Static extern voidOpen the hover window ();#endif}
The above code is simple #define BAIDUSDK. Define a preprocessing command variable (it is a token)
#if (BAIDUSDK) {//If the tag is defined
The code inside will be compiled
}
This is the implementation code selection compile O (∩_∩) o~
iOS uses C # preprocessing commands, multiple SDK coexistence