![]() ![]() This example results in a window which looks like this: Custom Editor Window created using supplied example.įor more info, take a look at the example and documentation on the EditorWindow page. MyFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3) MyBool = EditorGUILayout.Toggle ("Toggle", myBool) GroupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled) MyString = EditorGUILayout.TextField ("Text Field", myString) GUILayout.Label ("Base Settings", EditorStyles.boldLabel) ![]() Add menu item named "My Window" to the Window menu The following C# code shows how you can add GUI elements to your custom EditorWindow: using UnityEditor These classes add to the controls already available in the normal classes, so you can mix and match at will. In addition we provide some additional GUI controls, located in the editor-only classes EditorGUI and EditorGUILayout. You can use the same UnityGUI classes you use for your ingame GUI ( GUI and GUILayout). The actual contents of the window are rendered by implementing the OnGUI function. To have more control over what gets created, you can use GetWindowWithRect Implementing Your Window’s GUI This will create a standard, dockable editor window that saves its position between invocations, can be used in custom layouts, etc. This is done by using the function EditorWindow.GetWindow Like this: using UnityEngine ĮditorWindow.GetWindow(typeof(MyWindow)) The default behavior in Unity is to recycle windows, so selecting the menu item again would show existing windows. This is done by creating a function which is activated by the In order to show the window on screen, make a menu item that displays it. MyWindow.cs - placed in a folder called ‘Editor’ within your project. Then write your GUI controls in the inner OnGUI function. Make a class in this script that derives from EditorWindow. In order to make your Editor Window, your script must be stored inside a folder called “Editor”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |