anchor.diff:  Then we define *IExampleModuleInterface*, this is not necessary if you only have one editor module, but if you have more than that, this will handle event broadcasting for you.
   It is required that a module inherit from *IModuleInterface*, so our interface will inherit from the same class.
   
  -[source,cpp]
  -----
  -// IExampleModuleInterface.h
  -
  +.IExampleModuleInterface.h
  +[source,cpp]
  +----
   #include "ModuleManager.h"
   
   class IExampleModuleListenerInterface
  
positive.code: :source-highlighter: prettify | lang-glsl
  :figure-caption!:
  
  toc::[]
  
  == Setup Editor Module
  
negative.code: protected:
      TArray<TSharedRef<IExampleModuleListenerInterface>> ModuleListeners;
  };
  ----
  
  === ToolExmampleEditor.Build.cs
  
  This file you can copy from ToolExample.Build.cs. We added commonly used module names to dependency. Note we add "ToolExample" module here as well.
  
  .ToolExmampleEditor.Build.cs
  [source,cpp]
  ----
  PublicDependencyModuleNames.AddRange(
              new string[] {
                  "Core",
                  "Engine",
                  "CoreUObject",
                  "InputCore",
                  "LevelEditor",
                  "Slate",
                  "EditorStyle",
                  "AssetTools",
                  "EditorWidgets",
                  "UnrealEd",
                  "BlueprintGraph",
                  "AnimGraph",
                  "ComponentVisualizers",
                  "ToolExample"
          }
          );
  
  
  PrivateDependencyModuleNames.AddRange(
              new string[]
              {
                  "Core",
                  "CoreUObject",
                  "Engine",
                  "AppFramework",
                  "SlateCore",
                  "AnimGraph",
                  "UnrealEd",
                  "KismetWidgets",
                  "MainFrame",
                  "PropertyEditor",
                  "ComponentVisualizers",
                  "ToolExample"
              }
              );
  ----
  
  === ToolExampleEditor.h & ToolExampleEditor.cpp
  Here we define the actual module class, implementing *IExampleModuleInterface* we defined above. We include headers we need for following sections as well. Make sure the module name you use the get module is the same as the one you pass in *IMPLEMENT_GAME_MODULE* macro.
  
  .ToolExampleEditor.h
  [source,cpp]
  ----
  #include "UnrealEd.h"
  #include "SlateBasics.h"
  #include "SlateExtras.h"
  #include "Editor/LevelEditor/Public/LevelEditor.h"
  #include "Editor/PropertyEditor/Public/PropertyEditing.h"
  #include "IAssetTypeActions.h"
  #include "IExampleModuleInterface.h"
  
  class FToolExampleEditor : public IExampleModuleInterface
  {
  public:
      /** IModuleInterface implementation */
      virtual void StartupModule() override;
      virtual void ShutdownModule() override;
  
      virtual void AddModuleListeners() override;
  
      static inline FToolExampleEditor& Get()
      {
          return FModuleManager::LoadModuleChecked< FToolExampleEditor >("ToolExampleEditor");
      }
  
      static inline bool IsAvailable()
      {
          return FModuleManager::Get().IsModuleLoaded("ToolExampleEditor");
      }
  };
  ----
  
  .ToolExampleEditor.cpp
  [source,cpp]
  ----
  #include "ToolExampleEditor.h"
  #include "IExampleModuleInterface.h"
  
  class FToolExampleEditor : public IExampleModuleInterface
  {
  public:
      /** IModuleInterface implementation */
      virtual void StartupModule() override;
      virtual void ShutdownModule() override;
  
      virtual void AddModuleListeners() override;
  
  };
  
  IMPLEMENT_GAME_MODULE(FToolExampleEditor, ToolExampleEditor)
  
  
  void FToolExampleEditor::AddModuleListeners()
  {
      // add tools later
  }
  
  void FToolExampleEditor::StartupModule()
  {
      IExampleModuleInterface::StartupModule();
  }
  
  void FToolExampleEditor::ShutdownModule()
  {
      IExampleModuleInterface::ShutdownModule();
  }
  ----
  
  === ToolExampleEditor.Target.cs
  
  We need to modify this file to load our module in Editor mode (Don't change ToolExample.Target.cs), add the following:
  
  .ToolExampleEditor.Target.cs
  [source,cpp]
  ----
  ExtraModuleNames.AddRange( new string[] { "ToolExampleEditor" });
  ----
  
  === ToolExample.uproject
  
  Similarly, we need to include our modules here, add the following:
  
  .ToolExample.uproject
  [source,cpp]
  ----
  {
      "Name": "ToolExampleEditor",
      "Type": "Editor",
      "LoadingPhase": "PostEngineInit",
      "AdditionalDependencies": [
          "Engine"
      ]
  }
  ----
  
  Now the editor module should be setup properly.
  
  == Add Custom Menu
  
  Next we are going to add a custom menu, so we can add widget in the menu to run a command or open up a window.
  
  First we need to add menu extensions related functions in our editor module *ToolExampleEditor*:
  
  .ToolExampleEditor.h
  [source,cpp]
  ----
  public:
      void AddMenuExtension(const FMenuExtensionDelegate &extensionDelegate, FName extensionHook, const TSharedPtr<FUICommandList> &CommandList = NULL, EExtensionHook::Position position = EExtensionHook::Before);
      TSharedRef<FWorkspaceItem> GetMenuRoot() { return MenuRoot; };
  
  protected:
      TSharedPtr<FExtensibilityManager> LevelEditorMenuExtensibilityManager;
      TSharedPtr<FExtender> MenuExtender;
  
      static TSharedRef<FWorkspaceItem> MenuRoot;
  
      void MakePulldownMenu(FMenuBarBuilder &menuBuilder);
      void FillPulldownMenu(FMenuBuilder &menuBuilder);
  ----
  
  In the cpp file, define *MenuRoot* and add the implement all the functions. Here we will add a menu called "Example" and create 2 sections: "Section 1" and "Section 2", with extension hook name "Section_1" and "Section_2".
  
  .ToolExampleEditor.cpp
  [source,cpp]
  ----
  TSharedRef<FWorkspaceItem> FToolExampleEditor::MenuRoot = FWorkspaceItem::NewGroup(FText::FromString("Menu Root"));
  
  
  void FToolExampleEditor::AddMenuExtension(const FMenuExtensionDelegate &extensionDelegate, FName extensionHook, const TSharedPtr<FUICommandList> &CommandList, EExtensionHook::Position position)
  {
      MenuExtender->AddMenuExtension(extensionHook, position, CommandList, extensionDelegate);
  }
  
  void FToolExampleEditor::MakePulldownMenu(FMenuBarBuilder &menuBuilder)
  {
      menuBuilder.AddPullDownMenu(
          FText::FromString("Example"),
          FText::FromString("Open the Example menu"),
          FNewMenuDelegate::CreateRaw(this, &FToolExampleEditor::FillPulldownMenu),
          "Example",
          FName(TEXT("ExampleMenu"))
      );
  }
  
  void FToolExampleEditor::FillPulldownMenu(FMenuBuilder &menuBuilder)
  {
      // just a frame for tools to fill in
      menuBuilder.BeginSection("ExampleSection", FText::FromString("Section 1"));
      menuBuilder.AddMenuSeparator(FName("Section_1"));
      menuBuilder.EndSection();
  
      menuBuilder.BeginSection("ExampleSection", FText::FromString("Section 2"));
      menuBuilder.AddMenuSeparator(FName("Section_2"));
      menuBuilder.EndSection();
  }
  ----
  
  Finally in *StartupModule* we add the following before we call the parent function. We add our menu after "Window" menu.
  
  .ToolExampleEditor.cpp
  [source,cpp]
  ----
  void FToolExampleEditor::StartupModule()
  {
      if (!IsRunningCommandlet())
      {
          FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
          LevelEditorMenuExtensibilityManager = LevelEditorModule.GetMenuExtensibilityManager();
          MenuExtender = MakeShareable(new FExtender);
          MenuExtender->AddMenuBarExtension("Window", EExtensionHook::After, NULL, FMenuBarExtensionDelegate::CreateRaw(this, &FToolExampleEditor::MakePulldownMenu));
          LevelEditorMenuExtensibilityManager->AddExtender(MenuExtender);
      }
      IExampleModuleInterface::StartupModule();
  }
  ----
  Now if you run it you should see the custom menu get added with two sections.
  
  image::https://github.com/lxjk/lxjk.github.io/raw/master/images/sphericalslicedcone/fig2.png[, 600,align="center"]
  
  Next we can add our first tool to register to our menu. First add two new files:
  
  image::https://github.com/lxjk/lxjk.github.io/raw/master/images/sphericalslicedcone/fig2.png[, 600,align="center"]
  
  This class will inherit from *IExampleModuleListenerInterface*, and we add function to create menu entry. We also add FUICommandList, which will define and map a menu item to a function. Finally we add our only menu function *MenuCommand1*, this function will be called when user click on the menu item.
  
  .MenuTool.h
  [source,cpp]
  ----
  #include "ToolExampleEditor/IExampleModuleInterface.h"
  
  class MenuTool : public IExampleModuleListenerInterface, public TSharedFromThis<MenuTool>
  {
  public:
      virtual ~MenuTool() {}
  
      virtual void OnStartupModule() override;
      virtual void OnShutdownModule() override;
  
      void MakeMenuEntry(FMenuBuilder &menuBuilder);
  
  protected:
      TSharedPtr<FUICommandList> CommandList;
  
      void MapCommands();
  
      // UI Command functions
      void MenuCommand1();
  };
  ----
  
  On the cpp side, we got a lot more to do. First we need to define *LOCTEXT_NAMESPACE* at the beginning, and un-define it at the end. This is required to use *UI_COMMAND* macro.
  Then we start filling in each command, first create a *FUICommandInfo* member for each command in command list class, fill in *RegisterCommands* function by using *UI_COMMAND* marcro. Then in *MapCommands* function map each command info to a function. And of course define the command function *MenuTool::MenuCommand1*.
  
  In *OnStartupModule*, we create command list, register it, map it, then register to menu extension. In this case we want our item in "Section 1", and *MakeMenuEntry* will be called when Unreal build the menu, in which we simply add *MenuCommand1* to the menu.
  
  In *OnShutdownModule*, we need to unregister command list.
  
  .MenuTool.cpp
  [source,cpp]
  ----
  #include "ToolExampleEditor/ToolExampleEditor.h"
  #include "MenuTool.h"
  
  #define LOCTEXT_NAMESPACE "MenuTool"
  
  class MenuToolCommands : public TCommands<MenuToolCommands>
  {
  public:
  
      MenuToolCommands::MenuToolCommands()
          : TCommands<MenuToolCommands>(
          TEXT("MenuTool"), // Context name for fast lookup
          FText::FromString("Example Menu tool"), // Context name for displaying
          NAME_None,   // No parent context
          FEditorStyle::GetStyleSetName() // Icon Style Set
          )
      {
      }
  
      virtual void RegisterCommands() override
      {
          UI_COMMAND(MenuCommand1, "Menu Command 1", "Test Menu Command 1.", EUserInterfaceActionType::Button, FInputGesture());
  
      }
  
  public:
      TSharedPtr<FUICommandInfo> MenuCommand1;    
  };
  
  void MenuTool::MapCommands()
  {
      const auto& Commands = MenuToolCommands::Get();
  
      CommandList->MapAction(
          Commands.MenuCommand1,
          FExecuteAction::CreateSP(this, &MenuTool::MenuCommand1),
          FCanExecuteAction());
  }
  
  void MenuTool::OnStartupModule()
  {
      CommandList = MakeShareable(new FUICommandList);
      MenuToolCommands::Register();
      MapAction();
      FToolExampleEditor::Get().AddMenuExtension(
          FMenuExtensionDelegate::CreateRaw(this, &MenuTool::MakeMenuEntry),
          FName("Section_1"),
          CommandList);
  }
  
  void MenuTool::OnShutdownModule()
  {
      MenuToolCommands::Unregister();
  }
  
  void MenuTool::MakeMenuEntry(FMenuBuilder &menuBuilder)
  {
      menuBuilder.AddMenuEntry(MenuToolCommands::Get().MenuCommand1);
  }
  
  void MenuTool::MenuCommand1()
  {
      UE_LOG(LogClass, Log, TEXT("clicked MenuCommand1"));
  }
  
  #undef LOCTEXT_NAMESPACE
  ----
  
  When this is all done, remember to add this tool as a listener to editor module in *FToolExampleEditor::AddModuleListeners*:
  
  .ToolExampleEditor.cpp
  [source,cpp]
  ----
  ModuleListeners.Add(MakeShareable(new MenuTool));
  ----
  
  Now if you build the project, you should see your menu item in the menu. And if you click on it, it will print "clicked MenuCommand1".
  
  By now you have a basic framework for tools, You can run anything you want based on a menu click.
  
  image::https://github.com/lxjk/lxjk.github.io/raw/master/images/sphericalslicedcone/fig2.png[, 600,align="center"]
  
  == Advanced Menu
  
  