Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Get Even.current.OnMouseUp outside of editor window?

Discussion in 'Scripting' started by techmage, Dec 27, 2013.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I have an instance where I am dragging things around in the editor window and it relies on the EventType.MouseUp signal to release the dragging function. Which works just fine if the user keeps the pointer inside the editor window. But if the user drags outside the editor window and release the mouse it doesn't send the MouseUp event to finish the dragging code. How do I get around this?
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Well, where does the mouse end up?
     
  3. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    I solved this a few times, but I can't remember if I had a more elegant solution solution than: Listen to EditorWindow.Update and if the mouse isn't within the window and drag has started then end it.

    Listening to window update isnt usually that expensive but if you wanted you could register the listener when drag starts and deregister when it stops.