Add functionality to open a UWorld when clicking New Game button in main menu
This commit is contained in:
		
							parent
							
								
									085fd8ea46
								
							
						
					
					
						commit
						1f6d729d73
					
				@ -3,6 +3,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "MainMenuUIWidget.h"
 | 
					#include "MainMenuUIWidget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Kismet/GameplayStatics.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void UMainMenuUIWidget::NativeConstruct()
 | 
					void UMainMenuUIWidget::NativeConstruct()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Super::NativeConstruct();
 | 
						Super::NativeConstruct();
 | 
				
			||||||
@ -30,7 +32,11 @@ void UMainMenuUIWidget::NativeConstruct()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void UMainMenuUIWidget::NewGameButtonOnClicked()
 | 
					void UMainMenuUIWidget::NewGameButtonOnClicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// TODO: Implement Functionality
 | 
						// TODO: Replace this is a menu to confirm the user wants to start a new game
 | 
				
			||||||
 | 
						if (!NewGameLevel.IsNull())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel);	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void UMainMenuUIWidget::LoadGameButtonOnClicked()
 | 
					void UMainMenuUIWidget::LoadGameButtonOnClicked()
 | 
				
			||||||
 | 
				
			|||||||
@ -38,6 +38,9 @@ public:
 | 
				
			|||||||
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
 | 
				
			||||||
	TSubclassOf<class UUserWidget> OptionsMenuWidget;
 | 
						TSubclassOf<class UUserWidget> OptionsMenuWidget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
 | 
				
			||||||
 | 
						TSoftObjectPtr<UWorld> NewGameLevel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	UUserWidget* currentNewGameWidget;
 | 
						UUserWidget* currentNewGameWidget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user