Closed slasktotten closed 1 year ago
Can you change your signature to take the slice by value, like so
pub extern "C" fn mutate_slice_u32(slice: FFISliceMut<u32>) ...
and see if that helps?
Thanks for the quick reply!
Unfortunately that didn't change anything.
It also seems like the generated C# binding file is missing using Unity.Collections;
Required by: NativeArray<uint>
Hm, unfortunately I can't reproduce this.
In the example Unity project it does create a "constructor that takes 1 arguments" like so:
#if UNITY_2018_1_OR_NEWER
public SliceMutu32(NativeArray<uint> handle)
{
unsafe
{
this.data = new IntPtr(NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(handle));
this.len = (ulong) handle.Length;
}
}
#endif
The import is also present:
#if UNITY_2018_1_OR_NEWER
using Unity.Collections.LowLevel.Unsafe;
using Unity.Collections;
#endif
I would recommend to double-check the file backend_csharp_ui.rs
to see how the Unity bindings are created there. It's a bit convoluted, but follow bindings_match_reference()
, then the call to generate_bindings_multi("tests/output_unity/Assets")
.
If that doesn't help please post a minimal reproducible example, preferably as a Git repo somewhere.
Thanks I'll dig into it more. I am probably doing something silly :)
Still can't seem to make it work I'm afraid. I uploaded a minimal reproducible example. repro-example
There was a bug when these items were emitted, it only happened on Unsafe::UnsafePlatformMemCpy
; 0.14.15 should fix that.
I am using Interoptopus to generate C# bindings for Unity. This is my Generator:
I am trying to pass a mutable slice from C# to Rust and write into it like so:
The relevant generated binding looks like this:
Issue is I am getting an error in Unity saying: Assets/Plugins/Interop.cs(53,35): error CS1729: 'SliceMutu32' does not contain a constructor that takes 1 arguments
Am I doing anything especially crazy here?