- Home /
How to create a Event???
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");
}
}
Answer by Uzquiano · Mar 03, 2011 at 06:42 PM
Hello Andrea,
I'm sorry that I can't help you. However, maybe you could help me. I am doing my master thesis and right now I am facing your same problem. Please could you tell me how did you manage?
Thank you in advance.
Your answer
Follow this Question
Related Questions
TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer
Buttons that remove themselves when clicked mess up other gui elements 2 Answers
Is there an easy way to consume mouse/keyboard input events? 1 Answer
EventType.MouseDrag not working in WebPlayer 0 Answers
Trying to pick up and see paper - pop up GUI window to examine objects when clicked 3 Answers