I created a project using the mouse as the main control.
Then I created a library for connecting with another type of control. This library gives me the position of my pointer. I'd like to activate the mouse click when you press a button, so I can interact with the GUI and the buttons of the GUI.
My intention is not to change the code of the existing project, I would like only to add a class to do the click event.
I try this:
void Update() {
if (Input.GetKeyDown(KeyCode.A)) {
Event event = new Event();
event.mousePosition = new Vector2(10f, Screen.height - 10f);
event.type = EventType.mouseUp;
Event.current = event;
}
} // Update
void OnGUI() {
if (!(Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout)) {
Debug.Log(Event.current);
}
if (GUI.Button(new Rect(0f, 0f, 200f, 200f), "")) {
Debug.Log("Enter");
}
}