dansav
October 1, 2016, 6:09pm
1
To create a key event using unity’s event system I found the example below,
Event unityEvent = new Event();
unityEvent.keyCode = KeyCode.A;
unityEvent.type = EventType.KeyDown;
I’m having a hard time finding an example of how to create a mouse down event at a x,y location.
Event unityEvent = new Event();
unityEvent.type=EventType.MouseDown;
unityEvent.mousePosition=Vector2(100,100);
How do I trigger or fire the events?
Curious, but why are you creating events? If you just want to get mouse position, there are ways of doing that and then triggering methods off of it.
There are already ways of handling keyboard and mouse clicks and many of those other things.
dansav
October 1, 2016, 7:42pm
3
I’m trying to find something that would work on a machine that has no system mouse and keyboard or where the standalone is minimized.
In this case i would go another way, build an “action map” wich you can fill/change with eighter real keyboard/mouse events or by changeing it via code, and your things you called because of a keypress/mouseclick ect before, you now check the action maps content and exectute based on that instead.
Kiwasi
October 1, 2016, 11:12pm
5
Any reason why you are using the legacy GUI system? This whole thing becomes much easier with the new UI system.
Here is an example of a fake click with the new UI system.
1 Like
Ryiah
October 1, 2016, 11:49pm
6
Automating the editor rather than a game was my first thought.
Kiwasi
October 2, 2016, 1:28am
7
Possibly, but then I would ask why you are developing without a mouse.