2. What is Plugin?
• Libraries of native code written in C, C++,
Objective-C,….etc
• Allow your game code to call functions from
these libraries
3. Why do you need to
develop a Plugin?
• Unity3D can’t Do That
• Reuse C/C++/Objective-C components
• Difficult customize in Unity3D Assets Store
• Cross-Device
• Cross-Platform
• Security Issues
4. Plugins for Different Device
• iOS
#if UNITY_IOS
#else
#endif
if (Application.platform == RuntimePlatform.IPhonePlayer)
• Android
#if UNITY_ANDROID
#else
#endif
if (Application.platform == RuntimePlatform.Android)
5. iOS Plugins
• C/C++ Native Functions in xxx.mm
extern “C”{
float ReturnFloat()
{ return 10.5; }
}
• C# Dll Import
using System.Runtime.InteropServices;
[DllImport("__Internal")]
public static extern float ReturnFloat();