How can you access the Game screen and its properties from an Editor Script?

I’m encountering a problem writing Editor scripts in that I need access to the “Game” window and its Screen dimensions, but I don’t seem to be able to access them. This is particularly problematic because Camera.ScreenToWorldPoint is completely hosed from inside the editor scripts. Here’s an example of what’s wrong:

///////////////////////////////////////
// Inside MyGameObject.cs//////////////
///////////////////////////////////////
public void DoSomething(){

    // When previewing the game using the "Play" button, this works as expected.
    Debug.Log(Screen.width + " " + Screen.height);
    Vector3 adjustedPoint = renderCamera.ScreenToWorldPoint( vecScreenPoint );
    
}

///////////////////////////////////////
// Inside MyEditor.cs...
///////////////////////////////////////
override public void OnInspectorGUI(){
    MyGameObject g = target as MyGameObject;

    // But when I call from here, the Screen dimensions (both Screen and 
    // camera.ScreenToWorldPoint) report the dimensions of the inspector,
    // not the dimensions of the Game window
    g.DoSomething();
}

void OnSceneGUI(){
    MyGameObject g = target as MyGameObject;

    // And called from here, the dimensions match the active Scene window
    // but still, never the "Game" window!
    g.DoSomething();
}

So, is there some way to access the Game window? There doesn’t appear to be an OnGameGUI callback, unfortunately. If not, can you at least convince the camera to believe its screen dimensions match the Game window somehow? Is there some other utility that can offer this data? Can I manually translate screen to world without going through a camera?

I have answered my own question. So far, the only way I have found to do this is to call the DoSomething function from within a Camera’s OnPreRender / OnPostRender / OnRenderObject callbacks. In my case, OnPreRender was most appropriate.

///////////
//  CustomCamera.cs
///////////

using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class CustomCamera:MonoBehaviour{

  void OnPreRender(){
    if(Application.isPlaying) return; // Don't do this if application is running!
    MyGameObject[] gos = GameObject.FindObjectsOfType(typeof(MyGameObject)) as MyGameObject[];
    foreach(MyGameObject go in gos){
      go.DoSomething();
    }
  }
}

Calling go.DoSomething() from within a Camera’s render-related callbacks will always make the camera’s ScreenToWorldPoint (and also the Screen.width/height) dimensions reflect the value of the Game window’s width and height.