Access array of structures from jslib

Hello @brendanduncan_u3d , @GroovyFox , @gtk2k @pohype . Sorry for "at"ing all of you, but you guys are the best at this. I have a question. So…I know how to make a shared array and set the array from the jslib side, as explained here . However, imagine that instead of having a float array, I have an array of structs, and all of structs only have floats. Essentially, I want to set this array of structs from the jslib side directly, as if it was an array of floats. I thought it would work using the Float32Array because my array of structs is, or should be, essentially, an array of floats, but it didn’t work.

I have something like this

[StructLayout(LayoutKind.Sequential)]
    public struct mystruct {
        [MarshalAs(UnmanagedType.R4)] public float float1;
        [MarshalAs(UnmanagedType.R4)] public float float2;
    }

public static mystruct[] sharedstructs;

Obviously there’s something missing, otherwise it would work…

The idea behind this is that by using structs the code is easier to understand, because properties are accessed instead of array positions…

Thank you for your time!

The issue is having an array of floats inside the struct as well. The first code I wrote actually works, but I failed to mention that what I actually have is this

[StructLayout(LayoutKind.Sequential)]
    public struct mystruct {
        [MarshalAs(UnmanagedType.R4)] public float float1;
        [MarshalAs(UnmanagedType.R4)] public float float2;
        [MarshalAs(UnmanagedType.LPArray, SizeConst = 10)] public float[] floatArr;
    }

public static mystruct[] sharedstructs;

the float array inside the struct makes it not work. Found the source of the problem…how to fix it though. That float array actually makes more sense to be an array instead of individual properties like the other floats.