Making a tilemap editor within the Unity Editor

Is it possible to customize the Unity Editor so that I could "paint" objects into my scene, like in a tilemap editor such as Mappy or TileStudio? Basically I want to be able to click on my scene and have an object added at that position on a specified plane and grid. Something a bit like the terrain editor's foliage paintbrush.

Can I use OnSceneGUI for this perhaps?

Ok, so here's what I've come up with: Make a custom editor for a "Tilemap" MonoBehaviour, and in it have an OnSceneGUI. In the OnSceneGUI, generate a controlID with GUIUtility.GetControlID and add the control as default with HandleUtility.AddDefaultControl. This way, the Unity Editor won't use your mouse clicks on the scene for selecting things, but instead you can do whatever you like with the clicks. Here's a simple example I wrote in Boo, that basically will move any part of the map that you click on by five units:

import UnityEditor
import UnityEngine

class TilemapEditor (Editor):
    def OnSceneGUI():
        controlID as int = GUIUtility.GetControlID(FocusType.Passive)
        if Event.current.type == EventType.mouseDown:
            hit as RaycastHit
            if Physics.Raycast(Event.current.mouseRay, \
               hit, Mathf.Infinity, 1 << (target as Tilemap).terrainLayer):
                Debug.Log("Hit a part of the terrain")
                hit.transform.position.y += 5
        if Event.current.type == EventType.layout:

Obviously it still needs a lot of work to be a real editor; this is just a proof of concept.

Yes, I think technically it's possible, because the terrain editor system itself is written using Unity's own Editor Scripting API, so anything done there - you can do.

Unfortunately this is an area that is not well documented at all in the manual - for example, the OnInspectorGUI manual page contains just two short sentences as a description, and no example at all! - so it may be tough going, but good luck with it!