0
\$\begingroup\$

First of all, I would like to point out that I am not a Unity developer. Most of the programming is related to web programming, but my friends and I set out to create an MVP of one product inside Unity, but unfortunately we can't find any real help, because we get thousands of different information.

We would like to connect a sensor - an accelerometer with an nRF52 chip to Unity, which would serve as a control device. The sensors we bought have iOS/Android native SDKs, but unfortunately they do not support Unity. That's why I'm interested in what would be the fastest and most cost-effective solution. Can native SDKs be used within Unity?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Presumably you started by checking the Unity documentation about this, where they explicitly outline how to incorporate native code libraries into a Unity project. What do you need answered here that is not already covered in the official docs and related tutorials? \$\endgroup\$
    – DMGregory
    Aug 3 at 17:07

1 Answer 1

1
\$\begingroup\$

In the past I have created separate programs to run in the background that interface with sensors or other hardware. These separate programs communicate with my unity program through UDP or TCP sockets, streaming data.

So the unity program tries to connect to the sensor program. And if successful, it opens a new thread that writes the streaming data to a data object in a thread safe manner. The unity main thread can then read from this data object every frame.

This is obviously a bit of a workaround compared to importing a library directly, but I’ve found it worked great for cases where sensors had python or otherwise incompatible SDKs. Might also work in your case if you can’t import the DLLs into your project. The lag on a localhost Connection is negligible compared to the time of a frame (usually around 16ms).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .