2

I am building a native objective-C plugin in Unity. I have a struct in unity that has the mesh data that I am trying to send to the Objective-C plugin.

My struct looks like this

public struct MeshData
{
    public float[] vertices;
    public int vertexCount;
    public int[] faces;
    public int faceCount;
    public byte[] faceClassifications;
    public float4x4 transformMatrix;
}

I looked into marshaling in C# but my plugin function doesn't get called. There is also no good documentation that explains how to do this.

Another thing I tried was to get and Intptr for the struct and then send it over to the Objective-C side but that approach failed as well.

I am not super experienced with moving pointers and converting memory to pointers in C# and then rebuilding them on the objective-C side.

How should I go about this?

3
  • An answer related to passing struct data to a dll was answered here. Their problem was also solved so it works as an example. Commented May 3, 2021 at 19:17
  • I don't think the answer is solving my problem, Sorry, I missed adding a very important detail in this, the arrays are variable length arrays so it is not possible to determine the actual size of the struct. Commented May 5, 2021 at 23:59
  • You will need to pass the size of the arrays as well as a pointer to the first element in the array then. Either something like this or like this. Commented May 6, 2021 at 19:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.