Interaction with scene view in editmode?

Trying to create editor, that capable of drawing texture on my tiled mesh. I can do that in runtime, but completely can’t understand editmode. Using Javascript, expect to receive “working” in the console on mousedown in sceneview… How can I do that?

#pragma strict
//using UnityEditor;
//@script ExecuteInEditMode()

class HexMaker extends EditorWindow {

    @MenuItem ("Window/HexMaker")
    static function ShowWindow () {
    EditorWindow.GetWindow (HexMaker);
    }

    function OnGUI () {
    }
      
    function OnSceneGUI () {
		if (Event.current.type == EventType.MouseDown){
			Debug.Log("working");
			//  Event.current.Use();
		}
    }  
}

EditorWindow’s do not support the OnSceneGUI message.

Instead you will need a custom Editor in order to achieve this. Here is a simple example of a custom editor:

#pragma strict
@CustomEditor(MyPlayer)
class MyPlayerEditor extends Editor {

    function OnSceneGUI() {
        if (Event.current.type == EventType.MouseDown) {
            Debug.Log("TEST");
        }
    }

}

The above example works with a custom MonoBehaviour script called MyPlayer. This will only work when a game object with “MyPlayer” attached is selected.

Example video: (please excuse my Autocomplete nightmare in MonoDevelop, I don’t usually use it for coding!)