#unity

unity-native-plugin

Unity Native Plugin API for Rust

6 releases (breaking)

0.5.0 Sep 15, 2021
0.4.1 Nov 28, 2020
0.4.0 Oct 28, 2020
0.3.0 Sep 12, 2020
0.1.1 Aug 31, 2020

#221 in Game dev

Download history 11/week @ 2022-04-22 62/week @ 2022-04-29 58/week @ 2022-05-06 119/week @ 2022-05-13 31/week @ 2022-05-20 56/week @ 2022-05-27 63/week @ 2022-06-03 32/week @ 2022-06-10 21/week @ 2022-06-17 26/week @ 2022-06-24 27/week @ 2022-07-01 16/week @ 2022-07-08 21/week @ 2022-07-15 35/week @ 2022-07-22 16/week @ 2022-07-29 24/week @ 2022-08-05

99 downloads per month
Used in unity-native-plugin-vulkan

MIT license

2.5MB
75K SLoC

Unity Native Plugin API for Rust

LICENSE (MIT)

Notice

  • WIP
  • Currently supports D3D11, D3D12, Vulkan
  • API is not stable.

How to use

  • Define in Cargo.toml
[dependencies]
unity-native-plugin = { version = "*", features = ["d3d11"] }

# * Support features
#    * d3d11 - IUnityGraphicsD3D11
#    * d3d12 - IUnityGraphicsD3D12
#    * profiler - IUnityProfiler
#    * profiler_callbacks - IUnityProfilerCallbacks
  • If you use Vulkan, define "unity-native-plugin-vulkan" in your dependencies.
[dependencies]
unity-native-plugin = "*"
unity-native-plugin-vulkan = "*"
  • Use a macro in lib.rs to define your entry points. Without this definition, UnityInterfaces cannot be used.
unity_native_plugin::unity_native_plugin_entry_point! {
    fn unity_plugin_load(interfaces: &unity_native_plugin::interface::UnityInterfaces) {
        // called UnityPluginLoad
    }
    fn unity_plugin_unload() {
        //  called UnityPluginUnload
    }
}
  • Use UnityInterface::interface, which is equivalent to IUnityInterfaces::GetInterface, to get the interface.
let intf = unity_native_plugin::interface::UnityInterfaces::get()
    .interface::<unity_native_plugin::d3d11::UnityGraphicsD3D11>();

Examples

Dependencies