Disable the cursor when right clicking in the Scene view, while in the editor ?

Is it possible to disable the cursor when right clicking in the scene view in the editor ?

Basically, I’d like to prevent the cursor from showing when exploring my scene using the WASD + Right mouse button.

Can we create scripts that are called at every frame and that allows us to extend the editor ?

I couldn’t really find a good solution since the editor only updates the scene view when the mouse is moving, so with this script the mouse only disappears if its in the scene view, right clicked, and moving.

Here’s what I got:

  1. Add the below script to a file called NoRightMouseInSceneEditor and place it in the Assets/Editor (make it if you need to)

    @CustomEditor (NoRightMouseInScene)
    class NoRightMouseInSceneEditor extends Editor {

     function OnSceneGUI ()
     {
     	if(Event.current.type == EventType.MouseDown && Event.current.button == 1)
     	{
     		Screen.showCursor = false;
     	}
     	else if(Event.current.type == EventType.MouseUp && Event.current.button == 1)
     	{
     		Screen.showCursor = true;
     	}
     }
    

    }

  2. create another script called NoRightMouseInScene and this doesn’t have to be in Editor. Then attach it to some gameobject in your scene like the camera.

Hope it kind of helps you.