Search Unity

Swallow mouse clicks in the editor?

Discussion in 'Scripting' started by cjddmut, Mar 3, 2014.

  1. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    179
    Is there any way to prevent left and right mouse clicks from being processed by Unity in the editor? Basically I'd like to use a mouse click for something specific (any be clicked anywhere) and then let clicks go back to normal.

    I've tried calling Event.current.Use() but either the Event.current.type is being ignore (by the sceneview at least) or the click is being processed before I'm catching it and not being marked as dirty.

    I've found that I can call HandleUtility.AddDefaultControl(0) and the scene won't process left click (or won't let me click on gameobjects at least) which would be a start but I'm not sure how to set it back.

    Thanks!
    C.J.
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Can you be more precise? Click where? Do what?
     
  3. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    179
    Sure.

    I have an editor script that is hooked into the sceneview (riding on the SceneView.onSceneGUIDelegate property) that performs an action on a selected GameObject. I want to use the left mouse button to confirm action complete and right mouse button for action cancel.

    I'm having some difficultly getting this to work right. If clicked in the sceneview then I can use left mouse to confirm the action but scene also processes the click which I do not want it to. If I click outside the scene view then it appears that my editor script does not get either the left or right mouse click event so I cannot confirm/cancel.

    So basically what I want is for my editor script (or some script) to be able to block mouse events for all parts of Unity (or at least as much as I can) so that I can leverage the clicks for confirm/canceland not care where the click actually occurred.

    Please let me know if that is unclear :).
    C.J.
     
  4. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    179
    Let rephrase what I'm looking for now.

    Right now, hooked into sceneview, I only get mousedown events if they are clicked on the sceneview. Is there anyways I can know if the mouse was clicked down anywhere in the unity editor?