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 Touchtest.zip 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

Steve

Fichier attachéTaille
Téléchargement pluginsource.zip3.59 Ko
Téléchargement touchtest.zip8.05 Mo
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.