void AddInputMappingContext(const UObject* WorldContext, class UInputMappingContext* IMC, int32 Priority)
{
if (APlayerController* PlayerController = GetLocalPlayerController(WorldContext))
{
if (UEnhancedInputLocalPlayerSubsystem* InputerSubsystem = GetLocalSubsystem<UEnhancedInputLocalPlayerSubsystem> (PlayerController))
{
InputSubsystem->AddMappingContext(IMC, Priority);
FModifyContextOption Options;
Options.bForceImmediately = true;
InputSubsystem->RequestRebuildControlMapping(Options, EInputMappingRebuildType::RebuildWithFlush);
}
}
}
void RemoveInputMappingContext(const UObject* WorldContext, class UInputMappingContext* IMC)
{
if (APlayerController* PlayerController = GetLocalPlayerController(WorldContext))
{
if (UEnhancedInputLocalPlayerSubsystem* InputerSubsystem = GetLocalSubsystem<UEnhancedInputLocalPlayerSubsystem> (PlayerController))
{
InputSubsystem->RemoveMappingContext(IMC);
}
}
}