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

目录

Editor-Slate

WorkSpaceMenu(Slate相关类)

Editor-Tab-界面刷新 


Editor-Slate

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

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

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

虚幻5-编辑器扩展开发Editor-Slate的TabManager结构如下_第1张图片

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

WorkSpaceMenu(Slate相关类)

虚幻5-编辑器扩展开发Editor-Slate的TabManager结构如下_第2张图片

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

{
    MenuBarBuilder.AddPullDownMenu(
		FText::FromString(TEXT("Tabs")),
		FText::GetEmpty(),
		FNewMenuDelegate::CreateRaw(this, &SPjcTabMain::CreateMenuBarTabs, TabManager),
		"Window"
	);
}

void SPjcTabMain::CreateMenuBarTabs(FMenuBuilder& MenuBuilder, const TSharedPtr TabManagerPtr)
{
	if (!TabManagerPtr.IsValid()) return;

#if !WITH_EDITOR
	FGlobalTabmanager::Get()->PopulateTabSpawnerMenu(MenuBuilder, WorkspaceMenu::GetMenuStructure().GetStructureRoot());
#endif

	TabManagerPtr->PopulateLocalTabSpawnerMenu(MenuBuilder);
}

 

Editor-Tab-界面刷新 

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

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

虚幻5-编辑器扩展开发Editor-Slate的TabManager结构如下_第3张图片

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

.h 代码

class SPjcTabAssetsUnused final : public SCompoundWidget
{

代码太多,.cpp 不贴了

void SPjcTabAssetsUnused::Construct(const FArguments& InArgs)
{
	SubsystemPtr = GEditor->GetEditorSubsystem();
	if (!SubsystemPtr) return;

	UContentBrowserSettings* ContentBrowserSettings = GetMutableDefault();
	if (!ContentBrowserSettings) return;

	ContentBrowserSettings->SetDisplayDevelopersFolder(true);
	ContentBrowserSettings->SetDisplayEngineFolder(false);
	ContentBrowserSettings->SetDisplayCppFolders(false);
	ContentBrowserSettings->SetDisplayPluginFolders(false);
	ContentBrowserSettings->bShowAllFolder = false;
	ContentBrowserSettings->bOrganizeFolders = false;
	ContentBrowserSettings->PostEditChange();

	Cmds = MakeShareable(new FUICommandList);
	Cmds->MapAction(FPjcCmds::Get().ScanProject, FExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::OnProjectScan));
	Cmds->MapAction(
		FPjcCmds::Get().CleanProject,
		FExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::OnProjectClean),
		FCanExecuteAction::CreateRaw(this, &SPjcTabAssetsUnused::CanCleanProject)

	);
//............................

 

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

额外的还是搞下代码

SPjcTabAssetsUnused.cpp 的600+行

虚幻5-编辑器扩展开发Editor-Slate的TabManager结构如下_第4张图片

//最后获得几个关键字:GetModuleAssetRegistry() UseFilterToExcludeAssets
void UPjcSubsystem::GetAssetsAll(TArray& Assets)
{
	if (GetModuleAssetRegistry().Get().IsLoadingAssets()) return;

	Assets.Reset();

	GetModuleAssetRegistry().Get().GetAssetsByPath(PjcConstants::PathRoot, Assets, true);

	// filtering assets that are in '/Game/__ExternalActors__' and '/Game/__ExternalObjects__' folders
	FARFilter Filter;
	Filter.bRecursivePaths = true;
	Filter.PackagePaths.Add(FName{*GetPathExternalActors()});
	Filter.PackagePaths.Add(FName{*GetPathExternalObjects()});
	GetModuleAssetRegistry().Get().UseFilterToExcludeAssets(Assets, Filter);
}

参考项目:

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

虚幻插件:ProjectCleaner

你可能感兴趣的:(UE5虚幻Unreal,ue5,editor,plugin,插件开发)