Native plugin for "all" unity targets with shared c++ code.
- Supports macOS (+editor), Windows (+UWP) (+editor), iOS, Android, WebGL
- Simple and clear build process
- Shared c++ code
- Shared Objective-C code for ios and mac targets
- Shared Swift code for ios and mac targets
- Debug/Release configuration
- Raw source code sample for iOS/WebGL target (useful for debug)
- Marshaling samples (strings, arrays, structs), manual marshaling
I compile all targets on macOS and use Windows only for windows targets.
- Setup environment variable
ANDROID_NDK_HOME
target to Android NDK - Open
plugin
folder - run
buildall.sh
, special params[-w add swift sample code] [-x generate xcode projects] [-r Release configuration] [-s copy sources for iOS target (useful for debug)] [-l webgl build]
- Define
SWIFT
in Unity Player Settings window -Scripting Define Symbols
setting - Swift target copy additional files in project, feel free to edit or remove them.
Dummy.swift
can be removed if you have another*.swift
files.SwiftPostProcessor.cs
configures Xcode project.
MacOS(+editor) dylibs are huge because contains all swift dylibs (see ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
)
Can't get working *.bc library right now (WIP)
opt: error loading file '<projectpath>/Assets/Plugins/unity_plugin/webgl/libunity_plugin.bc'ERROR:root:Failed to run llvm optimizations:
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
- Install Emscripten
- Activate Emscripten
source ./emsdk_env.sh
buildall.sh -l -s
works perfect, some include directives fail sometimes, simple place all *.cpp and *.h files in root Plugins folder
- Install CMake 3.6+, MSVS, UWP SDK (optional)
- Open
plugin
folder - run
buildall.bat
, special params[-r Release configuration]
See plugin/buildall.[sh|bat]
for more information.
- UnityNativeScripting and articles by Jackson Dunstan
- Unity3D manual iOS native plugins
- Integrating native iOS code into Unity
- Unity — How to Build a Bridge: iOS to Unity with Swift
- Unity3D manual Native c++ plugins for Android
- Android CMake guide
- ABI management
- Interop with Native Libraries
- unity-native-array by keijiro - example with array marshaling
- Unity c++ Native Plugin Examples
- [android] test x86 library
- [webgl] static library