unity-native-plugin

Crates.iounity-native-plugin
lib.rsunity-native-plugin
version0.7.0
sourcesrc
created_at2020-08-31 16:58:39.075143
updated_at2024-08-04 16:50:44.797253
descriptionUnity Native Plugin API for Rust
homepagehttps://github.com/aosoft/unity-native-plugin-rs
repositoryhttps://github.com/aosoft/unity-native-plugin-rs
max_upload_size
id283144
size81,202
(aosoft)

documentation

README

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

Commit count: 106

cargo fmt