当前位置:   article > 正文

虚幻5-编辑器扩展开发Editor-Slate的TabManager结构如下_ue5 slate

ue5 slate

目录

Editor-Slate

WorkSpaceMenu(Slate相关类)

Editor-Tab-界面刷新 


Editor-Slate

基本上,地球人都知道(我不是地球人)虚幻引擎的Editor界面(自定义)通过Slate管理

Slate的入口是方法::Construct()

所以我们知道了如下代码,产生如下的界面

  1. void SPjcTabMain::Construct(const FArguments& InArgs, const TSharedRef<SDockTab>& ConstructUnderMajorTab, const TSharedPtr<SWindow>& ConstructUnderWindow)
  2. {
  3. TabManager = FGlobalTabmanager::Get()->NewTabManager(ConstructUnderMajorTab);
  4. const TSharedRef<FWorkspaceItem> AppMenuGroup = TabManager->AddLocalWorkspaceMenuCategory(FText::FromString(PjcConstants::ModulePjcName.ToString()));

WorkSpaceMenu(Slate相关类)

当点击【Tabs】时,弹出界面Popup即可通过如下代码,获取WorkSpaceMenu(目测时虚幻引擎内置)

  1. {
  2. MenuBarBuilder.AddPullDownMenu(
  3. FText::FromString(TEXT("Tabs")),
  4. FText::GetEmpty(),
  5. FNewMenuDelegate::CreateRaw(this, &SPjcTabMain::CreateMenuBarTabs, TabManager),
  6. "Window"
  7. );
  8. }
  9. void SPjcTabMain::CreateMenuBarTabs(FMenuBuilder& MenuBuilder, const TSharedPtr<FTabManager> TabManagerPtr)
  10. {
  11. if (!TabManagerPtr.IsValid()) return;
  12. #if !WITH_EDITOR
  13. FGlobalTabmanager::Get()->PopulateTabSpawnerMenu(MenuBuilder, WorkspaceMenu::GetMenuStructure().GetStructureRoot());
  14. #endif
  15. TabManagerPtr->PopulateLocalTabSpawnerMenu(MenuBuilder);
  16. }

 

Editor-Tab-界面刷新 

这个界面的刷新 cpp代码又是如何实现的呢?

(很传统的UI做法:由上而下刷新,子对象一层层刷新;你要说先进么,其实Unity Editor 的IMGUI,无限刷新还比较先进一点,写法也更灵活一点)

关键在于SPjcTabAssetsUnused这个类,也肯定是继承 XXXWidget 的 

.h 代码

  1. class SPjcTabAssetsUnused final : public SCompoundWidget
  2. {

代码太多,.cpp 不贴了

  1. void SPjcTabAssetsUnused::Construct(const FArguments& InArgs)
  2. {
  3. SubsystemPtr = GEditor->GetEditorSubsystem<UPjcSubsystem>();
  4. if (!SubsystemPtr) return;
  5. UContentBrowserSettings* ContentBrowserSettings = GetMutableDefault<UContentBrowserSettings>();
  6. if (!ContentBrowserSettings) return;
  7. ContentBrowserSettings->SetDisplayDevelopersFolder(true);
  8. ContentBrowserSettings->SetDisplayEngineFolder(false);
  9. ContentBrowserSettings->SetDisplayCppFolders(false);
  10. ContentBrowserSettings->SetDisplayPluginFolders(false);
  11. ContentBrowserSettings->bShowAllFolder = false;
  12. ContentBrowserSettings->bOrganizeFolders = false;
  13. ContentBrowserSettings->PostEditChange();
  14. Cmds = MakeShareable(new FUICommandList);
  15. Cmds->MapAction(FPjcCmds::Get().ScanProject, FExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::OnProjectScan));
  16. Cmds->MapAction(
  17. FPjcCmds::Get().CleanProject,
  18. FExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::OnProjectClean),
  19. FCanExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::CanCleanProject)
  20. );
  21. //............................

 

(你要是说虚幻复杂么,也挺复杂,各种继承;你要说它简单么,也挺简单,反正就是一切面向对象;大部分功能又必须多加很多额外的类,特别是相当于各种Wrap,各种事件回调;)

额外的还是搞下代码

SPjcTabAssetsUnused.cpp 的600+行

  1. //最后获得几个关键字:GetModuleAssetRegistry() UseFilterToExcludeAssets
  2. void UPjcSubsystem::GetAssetsAll(TArray<FAssetData>& Assets)
  3. {
  4. if (GetModuleAssetRegistry().Get().IsLoadingAssets()) return;
  5. Assets.Reset();
  6. GetModuleAssetRegistry().Get().GetAssetsByPath(PjcConstants::PathRoot, Assets, true);
  7. // filtering assets that are in '/Game/__ExternalActors__' and '/Game/__ExternalObjects__' folders
  8. FARFilter Filter;
  9. Filter.bRecursivePaths = true;
  10. Filter.PackagePaths.Add(FName{*GetPathExternalActors()});
  11. Filter.PackagePaths.Add(FName{*GetPathExternalObjects()});
  12. GetModuleAssetRegistry().Get().UseFilterToExcludeAssets(Assets, Filter);
  13. }

参考项目:

 这个项目真的不收费么。。。。。开源么。。。。。。

虚幻插件:ProjectCleaner

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/646620
推荐阅读
相关标签
  

闽ICP备14008679号