I’m attempting to turn off mouse selection in the scene view window so that I can make a custom type of paintbrush. I can get OnSceneGUI to work so long as I have an object in the hierarchy selected that has an empty script named “Example” on it, but as soon as I deselect that object by clicking in the scene view window, OnSceneGUI ceases to function. Does anyone know how I can go about doing this without having to have the object in the hierarchy selected? Any help is appreciated!
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof (Example))]
public class ExampleEditor : Editor {
void OnSceneGUI () {
Debug.Log ("Interacted with Scene View");
if (Input.GetMouseButtonDown (0)) { //If the mouse button is pressed
Debug.Log ("Mouse was pressed");
HandleUtility.AddDefaultControl (GUIUtility.GetControlID (FocusType.Passive)); //Disable scene view mouse selection
}
if (Input.GetMouseButtonUp (0)) { //If the mouse button is released
Debug.Log ("Mouse was released");
HandleUtility.Repaint (); //Enable scene view mouse selection
}
}
}