4.22 Question: Can Subsystems utilize Exec console commands?

Hi,

I want to be able to have a global console command similar to “stat FPS”. Currently I’m putting these types of commands within my GameInstance class, but in the long run I don’t want to crowd that class with unnecessary things like console command. So it would be really great if I could create a subsystem to hold all of that functionality, but also be accessed globally in some way. Does anyone know if subsystems support exec (or console command) functions?

Thanks,
London

You can do the following.

void UMySubsystem::Initialize( FSubsystemCollectionBase& Collection )
{
    TestCmd = IConsoleManager::Get().RegisterConsoleCommand( TEXT("TestCmd"),
                                                             TEXT("This is a test console command."),
                                                             FConsoleCommandDelegate::CreateUObject( this, &UMySubsystem::Exec_TestCmd ),
                                                             ECVF_Default );
}


void UMySubsystem::Deinitialize()
{
    IConsoleManager::Get().UnregisterConsoleObject( TestCmd );
}


void UMySubsystem::Exec_TestCmd()
{
    // Do something...
}
2 Likes