- Home /
using system.windows.forms to set cursor position
I need to modify the cursor postion and "transport" from one location to the other.
this question mentioned to use System.Window.Forms
the problem is Im having a hard time referencing the dll in monodevelop. I clicked the edit referance button and checked the proper dll. I also added the using statement and used the proper
System.Windows.Forms.Cursor.Position command.
The project compiles correctly but when Unity compiles it I get the error
The type or namespace name Windows' does not exist in the namespace
System'. Are you missing an assembly reference?
Then when I come back to monodevelop System.Windows.Forms is no longer checked as an assembly referance and it no longer compiles.
Ive tried using save and build commands to save the settings, None seem to work, maby unity is actually incompatible with this assembly referance?
Im not using a webplayer, I know webplayers are incompatible with it.
Does anyone know what I might be doing wrong with setting up my referances, or possibly an alternate way to set the mouse cursor position?
Also note that this is for a special purpose program that I know for sure will always be used on a PC, so its ok if using system.windows namespace prevents it from being cross compatible.
Thanks
The namespace System.Windows.Forms encapsulates the Win32 Windowing system used primarily on Windows XP. I.e. it calls subsystem functions that creates windows and GUI elements for you in $$anonymous$$S Windows operating systems from XP and onwards, but ONLY on $$anonymous$$S Windows. Since the purpose of Unity is to provide a single framework for multiple platforms, using a platform specific windowing system seems to defeat that purpose... I could be wrong, though, I'm curious if more replies turn up.
Yes, you are correct and I try to avoid using OS functions and stick inside unity as much as possible. But my particular application requires me to set the mouse cursor position at the Operating system level since unity doesnt support that. I have read that it can be done with System.Windows.Forms.
$$anonymous$$aby what I read was incorrect though, I hope not.
additionally, it is known that my special purpose program will always be on a PC, so i dont need to worry about cross platform compatibility.
I may be wrong, but I think you need pro for that to work. Do you?
Answer by michael 4 · May 17, 2011 at 09:27 PM
Just found out that adding system.windows.forms.dll to assets/plugins seems to do the trick.
+1, neither the $$anonymous$$ono nor the $$anonymous$$S .NET's DLL of System.Windows.Forms is working for me. It says there is an "internal compiler error", when placed as an asset in my Unity project.
I'd like to find a DLL of it that works, so I can let the user rotate a first person camera without having the cursor always reset to the center by using Screen.lockCursor.
Although this trick did work in the Editor, it did not work for me when I tried to generate the Build. I always get the following error:
ArgumentException: The Assembly System.Deployment is referenced by System.Windows.Forms. But the dll is not allowed to be included or could not be found.