How to display text in an editor viewport

What would be the simplest way to display a text in an editor viewport (not in-game)?
Something like the one which indicates direction of the orthogonal views (left/top/front).
I’d like to display the orthographicSize value in the corner of each view (if applicable).

The editor GUI can be accessed via EditorGUI in the OnGUI() method.

You can display text/controls/whatever in the same way that you would do so in game on the GUI, simply using EditorGUI or EditorGUILayout.button/label/whatever instead.

Edit: I’m not particularly sure if the info above applies if you’re trying to put that stuff in the actual editor viewport, but if you’re ok with using an editor window (like the inspector) you can do it there.

Since I need to display viewport specific information, the text should be
draw onto each one separately.

UnityGUI has no concept of view ports. The UI acts globally on the whole screen

you will need to find the camera covering that area, use screen.height / width + normalized view rect data and calculate the proper positioning through that way

Sorry what I meant was that custom text on the inspector is of no use since
the value could be different in each and every viewport. Custom handles are
also out since it should work without any selection or game objects present
in the scene.

Actually, I do have a single GO, hidden from the inspector, maybe I could use
Gizmos.DrawLine() in there to draw some text… but that sounds hacky.

    [MenuItem ("Window/MyWindow")]
    static void Init () {
      MyWindow window = (MyWindow)EditorWindow.GetWindow (typeof (MyWindow));
      if(SceneView.onSceneGUIDelegate != window.OnSceneGUI)
      {
        SceneView.onSceneGUIDelegate += window.OnSceneGUI;
      }	
    }

    public void OnSceneGUI(SceneView view){
      Handles.Label(Vector3.zero, "Instance Id = " + view.GetInstanceID());	
    }

You will need to track which scene view is which (for example you could check that the scene view was of the type of your custom view).

Use the process dreamora suggested to place the text in the right spot (view.camera will have the details of the camera).

EDIT: Note it doesn’t have to be in a window, its just one example.

Excellent, thank you!

well this is good information. i have been having trouble with the problem. display a text but should be a simple way. anyways thank you