Reputation: 45
I'm working on a project using a USB interface device (see here), and trying to use the DLL provided in the SDK pack within my Unity application. The end goal is to allow Unity to access inputs and outputs from the hardware - functionality for this is provided by the DLL.
I added the DLL to the project, and tried to access it from a script.
using UnityEngine;
using System.Collections;
using k8055d;
public class DLLTest01 : MonoBehaviour
{
public k8055d usbHandler;
void Start(){}
}
Unity threw me an error. The error was:
Assets/Resources/Scripts/DLLTest01.cs(3,7): error CS0246: The type or namespace name `k8055d' could not be found. Are you missing a using directive or an assembly reference?
The DLL is definitely within the project's folder, and named 'k8055d.dll', what could be the cause of this and what can I do to get the DLL working with any games I happen to make for my hardware device?
I feel like this may have something to do with the .NET version that Unity is using but I'm not sure what I can do if that's the issue.
Upvotes: 4
Views: 17043
Reputation: 4687
I've checked the docs and your DLL is not a .NET one. It is compiled, so you'll need to use a Plugin to be able to use it with Unity3D. (You'll probably need to create a .NET wrapper around that native dll code.)
Documentation about how to create plugins is available at the Unity Manual
Upvotes: 2
Reputation: 1831
This answer from the unity forums should help you:
To use an external DLL in your game, just place it inside of your Unity Project, in the Assets directory. Then, next time Unity synchronizes Visual Studio/MonoDevelop project, it'll add the necessary references to the DLLs in your Visual Studio/MonoDevelop project.
So, try placing the DLL in your Assets
directory and see if that does it!
You could also try using DllImport, like so:
[DllImport("k8055d.dll")]
But as you say in your question it could very well be a .NET version issue.
Upvotes: 1