Search Unity

Extending functionality while in scene view.

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

  1. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    179
    I'm writing some quick scripts to extend functionality while manipulating objects in the scene view. Part of what I wanted to accomplish is performing quick tasks with hotkeys and I've found MenuItem information that allows me to do this (although, it seems I can't put a hotkey just on 'g' it makes it 'shift-g'?). Though that isn't really an option if an action requires more events.

    In order to do this I either need to be on some sort of update loop or to be registered for events (or be on an message loop?). It appears that you can receive events if you have an opened EditorWindow but I don't want a window for this and would like for it to sit in the backgroud while I interact with it with hotkeys.

    Here is a very specific example of what I'd like to accomplish. I'd like to select an object(s) in either scene view or the hierarchy and press 'g'. At this point these object's positions will move when I move the mouse until I click to confirm the action (this also means that I'd like that click to not register for anything else but one problem at a time).

    Could someone point me in the right direction?

    Thanks!
    C.J.
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Code (csharp):
    1.  
    2. SceneView.onSceneGUIDelegate
    3.  
    Hook yourself on that event, then go banana!
     
  3. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    179
    Thanks, this is leading me down a pretty good path it seems :).