Displaying a panel with text data
Sometimes, we want to create and display a new panel as part of an Editor Extension. In this recipe, we create a menu item that creates and displays a new panel, displaying some text information:

How to do it...
To display a panel with text data, follow these steps:
- In the
Project
panel, create a new folder,Editor
. - In your new
Editor
folder, create a new C# script-class namedInformationPanel.cs
, containing the following:
using UnityEditor; using UnityEngine; public class InformationPanel : EditorWindow { [MenuItem("My Game/Info Panel")] public static void ShowWindow() { GetWindow<InformationPanel>("My Game", true); } private void OnGUI() { GUILayout.Label("Hello editor world"); GUILayout.FlexibleSpace(); GUILayout.Label("Here is some important information"); } }
- After a few seconds, you should now see a menu named
My Game
appear, with menu itemInfo Panel
. - Select menu item
Info...