x


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");
        }   
    }
more ▼

asked Sep 02 '10 at 09:35 AM

Andrea 1 gravatar image

Andrea 1
92 2 3 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

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.

more ▼

answered Mar 03 '11 at 06:42 PM

Uzquiano gravatar image

Uzquiano
480 22 25 35

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3674
x166
x92
x88

asked: Sep 02 '10 at 09:35 AM

Seen: 1786 times

Last Updated: Sep 02 '10 at 09:35 AM