Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by simaldeff · May 21, 2010 at 08:45 AM · inputplugindllcustomhaptic

Can I use my own input device?

Hi,

My problem seems fairly simple. I am a research student at a Lab, and this lab has developed a haptic 3d input device. Naturally I am to do something with this device and Unity. I have DLLs to use in C# (using PInvoke).

So would it be possible to use both the device as a pointing device (like a 3D mouse) and an haptic device (force feedback) if I was to buy the Pro version of Unity? Can you add your own input device into unity?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Cyclops · May 21, 2010 at 01:45 PM

Yes you can, provided A) you have Pro (which can use Plugins, and B) the project is a stand-alone executable (browsers have security limitations).

Here's a similar Question where I listed some sample code that might make it more clear: How to import Neurosky Mindset data into Unity

On second thought, that code might be misleading - Neurosky provides some boilerplate code in a C# file, that is required to call the .dll. If you are starting from scratch, you would have to write code to use the Plugin that looks something like this:

// This tells unity to look up the function FooPluginFunction inside the plugin named "PluginName"
[DllImport ("PluginName")]
private static extern float FooPluginFunction ();

And you can download Unity Pro Trial. The trial version is only valid for 30 days, but if this is a short, one-time project, that might be enough to complete it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Greg 4 · Dec 16, 2010 at 03:10 PM

... A follow on...

I also am trying to link in a haptic device... I have it running on Android through bluetooth and windows through c/c++/and c# dlls

I understand that I should be able to get this running no problem with windows, but what about android or iphone?

Will Unity allow my code to connect to a bluetooth device and send and recieve packets?

If not could I do it if the device has an IP address with udp/tcp?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Texhas · Jan 20, 2011 at 09:39 PM

I have been able to call a objective-c dll from C# scripts thanks to the info you provided. However, I wish to receive callbacks from my C++ dll. I thought of using a delegate to catch the callbacks as I have done before, but I get errors saying I'm trying to JIT compile my delegate. Is there a way to get callbacks from a dll in unity?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ferraribeng · Jul 14, 2011 at 06:22 AM

Hi, sorry to budge in with another question relating to "using my own input device". I am using a 3D input device, which I believe is similar to haptic, posted by simaldeff. I have the DDL in the plugin folder. I was able to read the data from the input device using the DLL API.

I am now experiencing this problem. When I move the device, the data I read and displayed using Debug.Log, lagged by about 1 second. This is not good because whatever I want to animate in Unity cannot respond to me instantanteously. I have no idea what causes the lagging.

I wrote another program in C++ to read the data from the same DLL and display it. Interestingly, there is no lagging at all. Seem like the problem is interaction between Unity and the DLL.

I have been looking through the forum for anyone with similar problem and any advice and pointers will be deeply appreciated. Thanks.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rasamaya · Apr 10, 2014 at 04:28 AM 0
Share

Ever get the lag sorted ferraribeng?

avatar image ferraribeng · Feb 16, 2015 at 03:12 AM 0
Share

I resolve the problem by editing the DLL (in c++) to have a thread that read the data from the device continuously and process it to the format I want to use in Unity. I have another method to allow Unity to call and read the processed data. In this way, I don't get the lagging anymore.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

XInputDotNetPure plugin: Namespace could not be found. 1 Answer

How to call a custom object from a C# dll 1 Answer

Why does my 32-bit dll plugin(c++) work in Unity 4 and not in Unity 5 indy (Windows 32-bit editor) 0 Answers

Cant link PLUGIN.DLL with PLUGIN-EDITOR.DLL 1 Answer

Unity plugins 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges