Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use existing types on C# generated code #79

Open
ZhaoXiangXML opened this issue Feb 8, 2023 · 1 comment
Open

use existing types on C# generated code #79

ZhaoXiangXML opened this issue Feb 8, 2023 · 1 comment
Labels
c-backend-c# C# Backend enhancement Make existing things better. question Further information is requested

Comments

@ZhaoXiangXML
Copy link

ZhaoXiangXML commented Feb 8, 2023

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?

@ralfbiedert ralfbiedert added question Further information is requested c-backend-c# C# Backend enhancement Make existing things better. labels Feb 11, 2023
@ralfbiedert
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-backend-c# C# Backend enhancement Make existing things better. question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants