Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for querying registering/unregistering input processor #16

Open
wants to merge 4 commits into
base: Main
Choose a base branch
from

Conversation

dzeligmanriot
Copy link

@dzeligmanriot dzeligmanriot commented Jul 27, 2024

We use these API in a subsystem (that maybe should exist in the root plugin in some form? ) to unregister and register during breakpoints etc.

Some example code:

void UDebugGUISubsystem::HandleScriptException(const UObject* InObject, const FFrame& InFrame,
	const FBlueprintExceptionInfo& InInfo)
{
	if (InInfo.GetType() == EBlueprintExceptionType::Breakpoint)
	{
		UnregisterInputProcessor();
	}

	if (InInfo.GetType() == EBlueprintExceptionType::AccessViolation
		|| InInfo.GetType() == EBlueprintExceptionType::AbortExecution
		|| InInfo.GetType() == EBlueprintExceptionType::FatalError )
	{
		DisableGUI();
	}
}
`void UDebugGUISubsystem::HandlePausePIE(bool bIsSimulating)
{
	UnregisterInputProcessor();
}


void UDebugGUISubsystem::HandleResumePIE(bool bIsSimulating)
{
	RegisterInputProcessor();
}`

void UDebugGUISubsystem::UnregisterInputProcessor()
{
	if(bDebugGuiOpen && ImGui::GetCurrentContext() != nullptr)
	{
		TSharedPtr<FImGuiContext> ActiveContext = FImGuiContext::Get(ImGui::GetCurrentContext());
		if(ActiveContext.IsValid())
		{
			ActiveContext->UnRegisterInputProcessor();
		}
	}
}

void UDebugGUISubsystem::RegisterInputProcessor()
{
	if(bDebugGuiOpen && ImGui::GetCurrentContext() != nullptr)
	{
		TSharedPtr<FImGuiContext> ActiveContext = FImGuiContext::Get(ImGui::GetCurrentContext());
		if(ActiveContext.IsValid())
		{
			ActiveContext->RegisterInputProcessor();
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant