create a sphere with script, confusion.

Hi, I want to create a sphere at the current cams location via a key short cut. From what i read and what I have seen the menuitem can not be used to get such data to do this ( no gizmo or a way to get the cam location )So I need the menuitem to call another class.

How can I create a class that runs all the time, or based off of an event. I know I can use
[editor.CustomEditor(typeof(…))]
To invoke a class form that type but can not find a way to do it based on a mouse move,key event, or continuously.

You can use an editor script like the one below to place a sphere at the camera position:-

@MenuItem ("GameObject/Sphere at camera position _c")
static function DoSomething (command : MenuCommand) {
    if (Camera.current != null) {
    	var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
    	sphere.transform.position = Camera.current.transform.position;
    }
}

Place this script in the Editor folder and you should see an extra item on the GameObject menu: “Sphere at camera position”. This uses C as the keyboard shortcut, so when you press C, you should get a new sphere where the camera is.