MenuBuilder.AddMenuEntry(MenuToolCommands::Get().MenuCommand1) Void MenuTool::MakeMenuEntry(FMenuBuilder &menuBuilder) UI_COMMAND(MenuCommand1, "Menu Command 1", "Test Menu Command 1.", EUserInterfaceActionType::Button, FInputGesture()) Ĭonst auto& Commands = MenuToolCommands::Get() įExecuteAction::CreateSP(this, &MenuTool::MenuCommand1),ĬommandList = MakeShareable(new FUICommandList) įToolExampleEditor::Get().AddMenuExtension(įMenuExtensionDelegate::CreateRaw(this, &MenuTool::MakeMenuEntry), TEXT("MenuTool"), // Context name for fast lookupįText::FromString("Example Menu tool"), // Context name for displayingįEditorStyle::GetStyleSetName() // Icon Style Set #include "ToolExampleEditor/ToolExampleEditor.h"Ĭlass MenuToolCommands : public TCommands MenuBuilder.AddMenuSeparator(FName("Section_2")) MenuBuilder.BeginSection("ExampleSection", FText::FromString("Section 2")) MenuBuilder.AddMenuSeparator(FName("Section_1")) MenuBuilder.BeginSection("ExampleSection", FText::FromString("Section 1")) Void FToolExampleEditor::FillPulldownMenu(FMenuBuilder &menuBuilder)
Void FToolExampleEditor::MakePulldownMenu(FMenuBarBuilder &menuBuilder)įText::FromString("Open the Example menu"),įNewMenuDelegate::CreateRaw(this, &FToolExampleEditor::FillPulldownMenu), MenuExtender->AddMenuExtension(extensionHook, position, CommandList, extensionDelegate) Void FToolExampleEditor::AddMenuExtension(const FMenuExtensionDelegate &extensionDelegate, FName extensionHook, const TSharedPtr &CommandList, EExtensionHook::Position position) 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.TSharedRef FToolExampleEditor::MenuRoot = FWorkspaceItem::NewGroup(FText::FromString("Menu Root")) 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.js - 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”.
Create a script that derives from EditorWindow.Making a custom Editor Window involves the following simple steps: Custom Editor Interface by Serious Games Interactive used for scripting cutscene actions This is a great way to add a user interface to a sub-system for your game. More info See in Glossary or any other built-in ones. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. Think of each unique Scene file as a unique level. More info See in Glossary, Scene A Scene contains the environments and menus of your game. These behave just like the Inspector A Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. You can create any number of custom windows in your app.