Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Disable Unity's Editor Functionality

Discussion in 'Immediate Mode GUI (IMGUI)' started by fabianzz, Feb 3, 2017.

  1. fabianzz

    fabianzz

    Joined:
    Nov 24, 2012
    Posts:
    39
    Ok so, I know this sounds weird but stay with me...
    I'm creating a game which Unity is totally the correct choice for from an engine perspective, but from an editor perspective it's not suited at all.

    For example, the game will be 3D tile based, there will be no primitives - only prefabs can be placed (which themselves can contain primitives) and it revolves around a voxel terrain system with a custom editor.

    Now, I've created the editors for most of this, but I'm facing the issue that Unity's Editor forces it's own input mechanisms. Almost every key is bound and the default inspector, hierarchy and toolbar are all visible and actively usable. Default gizmos are always visible for selected objects and the object selection mechanism itself is inappropriate.

    The simplest solution I know of is to make my editor part of the game itself, but I would then sacrifice the ability to use Unity scene files, editor API (asset manager, gizmos etc), baked lighting, navmesh system and much more.

    Is there a way to disable or override the editor features, such as to disable default gizmos on certain object types? The menus aren't much of a problem as my own can be docked on top of them, but when you have 2 translation gizmos it gets confusing. Overriding or disabling the selection tool would also be useful.

    Also, is there a way to override or disable Unity editor hotkeys?

    Edit: it seems Tools.hidden can do most of what I want.
     
    Last edited: Feb 3, 2017
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    You can override a lot of stuff in Unity Editor, examples:
    - Hides the Tools(Move, Rotate, Resize) on the Scene view:
    Code (csharp):
    1. Tool.hidden = true;
    - Prevent selection in SceneView:
    Code (csharp):
    1. SceneView.onSceneGUIDelegate += OnSceneGUI;
    2. OnSceneGUI()
    3. {
    4.     HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
    5. }
    - To override hotkeys you can use Event like this:
    Code (csharp):
    1. SceneView.onSceneGUIDelegate += OnSceneGUI;
    2. OnSceneGUI()
    3. {
    4.     if(Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.E)
    5.     {
    6.         Event.current.Use();
    7.     }
    8. }
     
    fabianzz likes this.
  3. fabianzz

    fabianzz

    Joined:
    Nov 24, 2012
    Posts:
    39
    Thanks for that. I literally just discovered Tools.hidden before reading that! Seems like I'll be able to do this without a custom SceneView as I thought would be required.