Skip to content

Customizing Categories

Valentin Plyasinov edited this page Aug 12, 2022 · 7 revisions

Plugin supports custom subsystem categories that will display in table.

To create a custom category for your special subsystems follow these steps:

  1. Add SubsystemBrowser module dependency in Build.cs

Since Subsystem Browser is an editor module it is recommended to access it only from other editor modules

When using a regular game module dependency has to be guarded with if (Target.bBuildEditor)

PrivateDependencyModuleNames.Add("SubsystemBrowser");
  1. Declare functions for category registration and subsystem selector in your module

Since Subsystem Browser is an editor module it is recommended to access it only from other editor modules

When using a regular game module access to editor-only types and headers has to be guarded with #if WITH_EDITOR

#include "SubsystemBrowserModule.h"

void RegisterSubsystemCategoryCustomizations();

struct FMyEditorModule : public IModuleInterface
{
       virtual void StartupModule() override
       {   // Call it on startup of your editor module
           RegisterSubsystemCategoryCustomizations();
       }
};
  1. Define class that will represent category
struct FSubsystemCategory_Game : public FSubsystemCategory
{
	FSubsystemCategory_Game()
	{
                // Configure display
		Name = TEXT("GameCategory");
		Label = INVTEXT("Game Subsystems");
		SortOrder = 50;
	}

        // Show category by default 
	virtual bool IsVisibleByDefault() const override { return true; }
        // Here is your subsystem selection logic 
	virtual void Select(UWorld* InContext, TArray<UObject*>& OutData) const override
	{
                
		for(UGameSubsystemClass* const  Instance: TObjectRange<UGameSubsystemClass>())
		{
			if (Instance->GetWorld() == InContext || !InContext)
			{
				OutData.Add(Instance);
			}
		}
	}
};
  1. Register custom category in plugin
void RegisterSubsystemCategoryCustomizations()
{
	FSubsystemBrowserModule& Module = FModuleManager::LoadModuleChecked<FSubsystemBrowserModule>(TEXT("SubsystemBrowser"));
	Module.RegisterCategory<FSubsystemCategory_Game>();
}
  1. Enjoy working with subsystems
Clone this wiki locally