none
How to implement NuiAccelerometerGetCurrentReading in Unity? RRS feed

  • General discussion

  • Hi

    So, I'm trying to implement NuiAccelerometerGetCurrentReading in Unity3D.

    http://msdn.microsoft.com/en-us/library/nuisensor.inuisensor.nuiaccelerometergetcurrentreading.aspx

    What type of Vector4 does this method fill? Is it XNA? Am I supposed to define the Vector4 struct myself in Unity, or do I have to import XNA (what seems overkill)?

    Carl Emil

    Tuesday, March 4, 2014 11:02 AM

All replies

  • To further explain, my wrapper function looks like this in Unity:

    [DllImportAttribute(@"Kinect10.dll", EntryPoint = "NuiAccelerometerGetCurrentReading")]
    public static extern int NuiAccelerometerGetCurrentReading( ref Vector4 data );

    And I get an EntryPointNotFoundExacption. I'm passing a UnityEngine.Vector4 and I'm thinking perhaps that's the problem, but what else to pass?

    Carl Emil

    Friday, March 7, 2014 10:35 AM
  • A Vector4 is defined as a data structure of 4 floats. Do you have an equivalent Unity data structure where you can marshal the memory over into Unity that will match that?

    Carmine Sirignano - MSFT

    Friday, March 7, 2014 10:58 PM
  • I tried to create my own vector4 struct, just to make sure it was not the UnityEngine.Vector4. Still get the same exception. Still stuck. What am I missing?

    public struct NuiVector4 { public float x, y, z, w; }

    Friday, March 28, 2014 3:16 PM
  • You would have to check with the Unity team to ensure you can do this type of Interop with the Kinect .dll. Unity doesn't use the full .Net implementation and could be the issue.

    Carmine Sirignano - MSFT

    Friday, March 28, 2014 7:51 PM