Object Painter Editor Help

Hello I'm trying to complete my "Object Painter" editor.. but no luck. What it should do: paint objects in scene based on raycasts and use curently selected prefab as a source for instancing. Also replacing "Fire1" with other right mouse button would be nice. BUG: not instancing

class ObjectPainter extends EditorWindow {

static var thePaintPrefab:GameObject;
static var paintActive:boolean=false;
var buttonText:String;

@MenuItem("Custom/Object Painter")
static function Init() {
    var window = GetWindow(ObjectPainter);
    paintActive = false;
    window.position = Rect(0,0,170,60);
    window.Show();
    thePaintPrefab = Selection.activeGameObject;
}

function OnGUI() {

    var newObject : GameObject = EditorUtility.InstantiatePrefab(thePaintPrefab) as GameObject;

    if (paintActive) {
        buttonText = "-=ACTIVE=-";
    } else {
        buttonText = "-Paint-";
    }
    if(GUI.Button(Rect(3,25,position.width-6, 30),buttonText)){
        if (paintActive == false) {
            thePaintPrefab = Selection.activeGameObject;
            Debug.Log("Prefab: " + thePaintPrefab.name);
        }
        paintActive = !paintActive;
    }
}

function Update() {
    if (paintActive) {
        if (Input.GetButtonDown("Fire1")) {
            var ray : Ray = SceneView.lastActiveSceneView.camera.ScreenPointToRay(Input.mousePosition);
            var hit : RaycastHit;

            if (Physics.Raycast(ray, hit, 100))     {
                var otherObj : GameObject = hit.collider.gameObject;
                Debug.Log("Hit: " + otherObj.name);

                var newPos : Vector3 = new Vector3(hit.point.x,hit.point.y, hit.point.z );
                if (thePaintPrefab) {
                    var newObject : GameObject = EditorUtility.InstantiatePrefab(thePaintPrefab) as GameObject;
                    newObject.transform.position = newPos;
                    Debug.Log("Prefab: " + thePaintPrefab.name+" @pos "+ newPos);
                }
            }
        }
    }
}

}

I'll guess it's because you use the MainCamera. In what view do you want to paint? SceneViews have their own cameras you can get the camera of the last active SceneView with:

SceneView.lastActiveSceneView.camera

Unfortunately the SceneView class is not documented yet, but with C# and visual studio intelliSense can show you all public classes. AFAIK MonoDevelop have also a similar feature, but i never really used MonoDevelop yet ;)

There's also the `SceneView.sceneViews` array that contains all open scene views.