ralfbiedert/interoptopus

use existing types on C# generated code

ZhaoXiangXML opened this issue · 1 comments

For instance in rust we have

#[ffi_type]
#[repr(C)]
pub struct Vec2 {
    pub x: f32,
    pub y: f32,
}

#[ffi_function]
#[no_mangle]
pub extern "C" fn my_function(input: Vec2) -> Vec2 {
    input
}

I'd like to use UnityEngine.Vector2 instead of generated Vec2 type.

        /// Function using the type.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "my_function")]
        public static extern UnityEngine.Vector2 my_function(UnityEngine.Vector2 input);

Is this currently possible?

This isn't supported out of the box. You might get away by setting name and namespace in ffi_type (see reference project), resolve the namespace to UnityEngine, and avoid emitting it in your Interoptopus C# config. I haven't tried this though. Please post results if you try.