Delsys API Integration with Unity
You can download the sample project from here
Download the API package.
For this tutorial, we'll be using the NuGet for Unity plugin. This is not required, but it simplifies obtaining the API's dependencies.
- Install NuGet for Unity from the Asset store.
- Install Stateless and Portable.Licensing NuGet packages.
- Extract each NuGet package -- the API, Stateless, and Portable.Licensing -- with a zip extractor.
Copy each dll (Stateless from the lib/net45 folder, Portable.Licensing, and all of the Delsys API dlls) to the Assets folder of your Unity project.
Delete the NuGet packages and NuGet config files to ensure no duplicate dependencies. Your project should now look something like this:
- Add code to copy the SiUSBXp.dll to the output folder if necessary.
//
public class SomeUnityScript : MonoBehaviour
{
// Copy the USB Driver at startup, before using any API functions.
void Start()
{
CopyUSBDriver();
// Rest of your program . . .
}
// . . .
// Copies the SiUSBXp.dll to the parent folder of StreamingAssets, placing it next to the Unity executable.
public void CopyUSBDriver()
{
string unityAssetPath = Application.streamingAssetsPath + "/SiUSBXp.dll";
string adjacentToExePath = Application.dataPath + "/../SiUSBXp.dll";
if (!File.Exists(adjacentToExePath))
{
File.Copy(unityAssetPath, adjacentToExePath);
}
}