Editor Crashed When Loading Main Menu


void UPzzzleGameInstance::LoadMenu()
{
	if (this->Menu == nullptr)
	{
		UE_LOG(LogTemp, Error, TEXT("No Widget Class  /Game/UI/MenuSystem/"));
		return;
	};
	
	APlayerController* PlayerController = GetFirstLocalPlayerController();
	if (PlayerController)
		PlayerController->bShowMouseCursor = true;

	if (Widget)
	{
		FInputModeUIOnly Mode;
		/*	Mode.SetWidgetToFocus(this->Menu.Get());*/

		Mode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
		PlayerController->SetInputMode(Mode);

		Widget->AddToViewport();
		Widget->bIsFocusable = true;
		Widget->SetMenuInterface(this);
	}
	else
	{
		UE_LOG(LogTemp,Error,TEXT("ERROR in LoadMenu() function failed to load Widget"))
	}

};

hey now its working on unreal version 4.27 but when I run its copy on unreal engine 5 its crashing here the

Is the game instance init calling the Super init?

yeah!

What is the code at error line 127 of the game instance?
It usually indicates a failure to check for nullptr but you’d expect the same issue with 4.27


void UPzzzleGameInstance::LoadMenu()
{
	if (this->Menu == nullptr)
	{
		UE_LOG(LogTemp, Error, TEXT("No Widget Class  /Game/UI/MenuSystem/"));
		return;
	};
	
	APlayerController* PlayerController = GetFirstLocalPlayerController();
	if (PlayerController)
		PlayerController->bShowMouseCursor = true;

	if (Widget!=nullptr)
	{
		FInputModeUIOnly Mode;
		/*	Mode.SetWidgetToFocus(this->Menu.Get());*/

		Mode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
		PlayerController->SetInputMode(Mode);
		if (Widget!=nullptr)
		{
			Widget->AddToViewport();
			Widget->bIsFocusable = true;
			Widget->SetMenuInterface(this);
		}

	}
	else
	{
		UE_LOG(LogTemp,Error,TEXT("ERROR in LoadMenu() function failed to load Widget"))
	}

};

The player controller reference is used without a null check the second time it is used to set the mode. This could be the issue but its hard to say not knowing what the line numbers are.

Privacy & Terms