The Unity Multi Touch Source (finally)

Hey Everybody

Here is the source for the CPP and C# files needed to implement the Multi Touch Plugin DLL referred to in the previous post. Sorry it took so long to publish. Just download the zip and they're both there. I've also uploaded which is a very bad Unity app which uses the plugin - seriously - it’s just an empty app which talks to the plugin and displays the touch info on screen. Tested on win7 and win8 desktop, although there are a million combinations of touch screen and OS / Driver etc & so I haven’t tried them all, so its uploaded as-is;and I make no guarentees about running correctly. I also make no guarantees about the exe itself - I scanned it before uploading but - as always - scan before you run!

DLLMain.cpp is the complete source for the plugin.dll. There have been a couple of small changes since the original blog, including changing it to receive a WCHAR array from unity instead of a char * for the name of the window. This seems to be something that’s changed in Unity 4.x - haven't investigated why exactly. This took a bit of finding, and probably explains why some people had problems making it work at the final hurdle.

Check1.cs is the Unity script which you will attach to either your landscape or camera - whatever - to call the plugin.  Beyond that its fairly easy to build and use.

Here is what I did to build and debug it.

  1. Create a new VisualStudio 2008 project (I think it works on 2010 too).  You want a DLL.
  2. Add the DLLMain.cpp file as the only source file.  No additional includes, no extra libs.
  3. Change the Output Directory in Configuration Properties/General in the Properties dialog for the DLL project to point to  the Assets/plugins folder in your Unity project.
  4. Build the project.  If you have Unity loaded and it was successful you should see the plugin appear in your assets/plugins folder on the project page.
  5. Copy Check1.cs to the assets folder of your Unity project and attach the script to an object in your scene.  I added it to my landscape.
  6. Build the Unity project.

If all is successful then the dll should get loaded when you run your Unity app. 

If you want to debug, you can rather neatly run the DLL project in VisualStudio and when prompted point at the the Unity exe for your app. VS will load the app and breakpoints in the DLL source in VS should hit appropriately when your app calls the plugin.

I think thats all you need.  Let me know how you get on.

Happy coding


Package icon pluginsource.zip3.59 KB
Package icon touchtest.zip8.05 MB
For more complete information about compiler optimizations, see our Optimization Notice.



It Hi @steve-hughes (Intel) 

I'm doing an Unity application to recognize objects. I had changed the dll to add cxContact and cyContact to g_TouchData.

It works fine when i use on Unity and can read contact data of object size, but there is a bug when i put only 2 objects on touch screen.

If I put 1 object --> works ok, and receive contactX and Y

If I put 2 objects --> receive time, position well, but contact values of 1st and 2nd show 600 for both objects. 

If I put 3 or mores objects --> works fine and read ALL the object size. Also the 1th and 2nd.

Can you help me to solve this issue.

Thanks you.


Thank you!!!! I am using now this in all my applications. And thanks to you our applications are working great in an IR frame, but we became stuck on Windows, we need to change platform to Linux. Still searching for a solution, has been a while now. Can you, please, help me one more time? 
If you have any directions or something like that I will be eternally grateful.


Hi. I followed the instructions trying to get this working on Unity 4.6.1 with windows 7 and a Dell P2314T

The TouchTest.exe included in the post works fine.  But when I try to drop the dll into my own unity project I get Number of TouchPoints:0.

Here's what I've tried.

1. I Create a new unity project called TouchTest and save a Scene called TouchTest. if not change TouchTest in check1.cs to the project name or scene name. I'm not sure which one it uses.

1. Download both links.  Find Touchoverlay.dll in the folders and import it into unity project. Create a plugins folder and drop it into the plugins folder.

2. Import Check1.cs and drop it onto the Camera.

All I get in the editor is

Number of Touch Points:0

When doing a build I get nothing on the screen no words etc.

Before I had the project and scene named differently than TouchTest I got the 128 touch points and 0,0,0 down the screen.

Could someone post a unity project to look at. Or if I have to rebuild could someone post instructions on how to rebuild this in Visual Studio 2013. 

Thank you,



The TouchTest application which I downloaded from your post works well, but I'm having a hard time importing the .dll into my project in Unity. I keep receiving a "Dllnotfoundexception". It is pointing to the TouchOverlay.dll in the plugins folder, which I've confirmed exists. 

Would it be possible to download your Unity Project source for this so that I can take a look at it and see where I'm going wrong? 



Hello Steve,

i am working on a project in unity, will be build for windows 8 os.

i used your code to make the executable multi touchable , i am getting errors in unity while Building the exe.

i have been able to create the plug in and i have put the files built in visual studio in unity plugin folder.

and i have applied the check1.cs file on any object in my scene.

i have set and done all settings told by you in your tutorial.

and i selected unity32app in visual studio , radio button dll , then empty project. as u have said in your comment.

please check the image i am sending you the link.

i am sending u the link of the image with the errors that i am getting in unity while building the exe.

i am not being able to figure it out what is wrong.

here is the link:

please go through it , and let me know where am i wrong.







Hey Steve, 

i followed your steps and integrated your solution in my unity windows 8 project. it works very well, but i need some information about the flags, because the application i am working on is state based. i tried to extend your tTouchData struct with DWORD m_Flags attribute and the unity wrapper structures (read from MSDN). i do not reset the id after TOUCHEVENTF_UP recognition, just update the flag and position. the reset is an if-statement after copy the tTouchData object in the result array, something like if(flag == upEvent) then reset...

i get the right states, but it seems, that there is an unequal amount of down and up events... quite strange behaviour. do i have to consider something else, that is important to recieve correct results ? or should i handle this in unity with own structures and c#?

hope you can help me! 


Hi Steve,
I am new to unity and working with touch controls. I have the plugin working, but I have difficulties interpreting the values I get for the coordinates, they're very large. Is there an easy way to convert them to window coordinates?

Thanks for your work!

Edit: I found out by observation that it's just dividing by 100 and inversing the y-axis.

Hi Steve,

I have been trying this out on a Acer T272HL multitouch screen with Windows 8 and Unity Pro 4.3.2f1. It registers all touches just fine but the problem is that it randomly leaves static dead touchpoints in the list. So if I move around with both hands on the screen (10 fingers) I quickly end up with 10-15 static touchpoints. If I keep moving around the amount of static touchpoints just keeps growing. Have you experienced this? Any idea how to fix it? Is there perhaps a CANCELLED state of touchpoints that you are not listening to and removing touchpoints?

Hi Jen

As far as I know the Window name is the same as the project name.  The project in the sample was called "New Unity Project 9".  If you export a windows executable, run it in a window, and look the title bar - that should tell you.  Copy that string exactly to your c# script and you should be good.

Good luck



I think I'm the only one that can't figure this out, but how do I find the name of my window?  I'm having the same issue as others with the touchpoint displaying 128, etc.  I've tried every name I can think of, combinations, etc and I apparently am not getting it.  Your executible package works great, but when I try to use the C# script with the TouchOverlay.dll in my own project I obviously don't have the correct window name.  Can you help this beginner?

Thanks! Jen


Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.