Showing posts with label dll. Show all posts
Showing posts with label dll. Show all posts

Oct 8, 2013

[Unity3d] C++ dll for iPhone and XBox 360

#if UNITY_IPHONE || UNITY_XBOX360

   // On iOS and Xbox 360 plugins are statically linked into
   // the executable, so we have to use __Internal as the
   // library name.
   [DllImport ("__Internal")]

   #else

   // Other platforms load plugins dynamically, so pass the name
   // of the plugin's dynamic library.
   [DllImport ("PluginName")]

   #endif
iOS and X-Box use dll as a static library. So, you should use "__internal" when importing. 

[Unity3d] How to use C++ dll in Unity3d

1. Make CLI  Class library project in Visual Studio. 


2.  Delete all files except main cpp  file. You don`t need other auto created files. 


3. Write down the codes you need like this. 

4.  Drag and drop the dll file to Unity Assets/Plugins. It is recommended that you use release mode rather than debug mode while building the project. 
(Make sure you drag and drop to Plugins folder. Other folders  may not work or cause errors.) 
5.  Create a C# script and attach it to a game object. Write code as below.  
 Then you will have value of '1102' in integer variable "nRet".