Agrarsense
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
AWindowActor Class Reference

#include <WindowActor.h>

Inheritance diagram for AWindowActor:
Inheritance graph
[legend]
Collaboration diagram for AWindowActor:
Collaboration graph
[legend]

Public Member Functions

 AWindowActor (const FObjectInitializer &ObjectInitializer)
 
void SetupWindow (int Width=1280, int Height=720, FString Title="Window", UTextureRenderTarget2D *TextureRenderTarget=nullptr)
 
void SetupTextureRenderTarget (UTextureRenderTarget2D *TextureRenderTarget)
 
void AddWidgetToWindow (UWidget *WidgetToAdd)
 
void RemoveWidgetFromWindow (UWidget *WidgetToAdd)
 
void ResizeWindow (int Width=1280, int Height=720)
 
TSharedPtr< FUnrealWindowGetUnrealWindow ()
 

Public Attributes

FOnWindowClosed OnWindowClosedDelegate
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 

Private Member Functions

void OnWindowClosed (const TSharedRef< SWindow > &Window)
 

Private Attributes

TSharedPtr< FUnrealWindowUnrealWindow
 

Detailed Description

Example Actor how to use FUnrealWindow to modify and create custom Window. Usage example: Create new blueprint based on this Actor - At blueprint BeginPlay call SetupWindow. To Add/Remove widgets call AddWidgetToWindow/RemoveWidgetFromWindow. To Resize window call ResizeWindow.

Definition at line 26 of file WindowActor.h.

Constructor & Destructor Documentation

◆ AWindowActor()

AWindowActor::AWindowActor ( const FObjectInitializer &  ObjectInitializer)

Definition at line 8 of file WindowActor.cpp.

8 : Super(ObjectInitializer)
9{
10 PrimaryActorTick.bCanEverTick = false;
11}

Member Function Documentation

◆ AddWidgetToWindow()

void AWindowActor::AddWidgetToWindow ( UWidget *  WidgetToAdd)

Definition at line 57 of file WindowActor.cpp.

58{
59 if (UnrealWindow.IsValid())
60 {
61 UnrealWindow->AddUWidgetToWindow(WidgetToAdd);
62 }
63}
TSharedPtr< FUnrealWindow > UnrealWindow
Definition: WindowActor.h:66

References UnrealWindow.

◆ BeginPlay()

void AWindowActor::BeginPlay ( )
overrideprotectedvirtual

Definition at line 39 of file WindowActor.cpp.

40{
41 Super::BeginPlay();
42}

◆ EndPlay()

void AWindowActor::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprotectedvirtual

Definition at line 44 of file WindowActor.cpp.

45{
46 Super::EndPlay(EndPlayReason);
47
48 // At EndPlay destroy Window
49 if (UnrealWindow.IsValid())
50 {
52 UnrealWindow->DestroyWindow();
53 UnrealWindow.Reset();
54 }
55}
FOnWindowClosed OnWindowClosedDelegate
Definition: WindowActor.h:54

References OnWindowClosedDelegate, and UnrealWindow.

◆ GetUnrealWindow()

TSharedPtr< FUnrealWindow > AWindowActor::GetUnrealWindow ( )
inline

Definition at line 49 of file WindowActor.h.

50 {
51 return UnrealWindow;
52 }

◆ OnWindowClosed()

void AWindowActor::OnWindowClosed ( const TSharedRef< SWindow > &  Window)
private

Definition at line 81 of file WindowActor.cpp.

82{
83 // Destroy this Actor when Window is closed
84 this->Destroy();
85}

References Destroy.

Referenced by SetupWindow().

◆ RemoveWidgetFromWindow()

void AWindowActor::RemoveWidgetFromWindow ( UWidget *  WidgetToAdd)

Definition at line 65 of file WindowActor.cpp.

66{
67 if (UnrealWindow.IsValid())
68 {
69 UnrealWindow->RemoveUWidgetFromWindow(WidgetToAdd);
70 }
71}

References UnrealWindow.

◆ ResizeWindow()

void AWindowActor::ResizeWindow ( int  Width = 1280,
int  Height = 720 
)

Definition at line 73 of file WindowActor.cpp.

74{
75 if (UnrealWindow.IsValid())
76 {
77 UnrealWindow->ResizeWindow(Width, Height);
78 }
79}

References UnrealWindow.

◆ SetupTextureRenderTarget()

void AWindowActor::SetupTextureRenderTarget ( UTextureRenderTarget2D *  TextureRenderTarget)

Definition at line 31 of file WindowActor.cpp.

32{
33 if (UnrealWindow.IsValid())
34 {
35 UnrealWindow->SetupComponent(TextureRenderTarget);
36 }
37}

References UnrealWindow.

Referenced by SetupWindow().

◆ SetupWindow()

void AWindowActor::SetupWindow ( int  Width = 1280,
int  Height = 720,
FString  Title = "Window",
UTextureRenderTarget2D *  TextureRenderTarget = nullptr 
)

Definition at line 13 of file WindowActor.cpp.

14{
15 if (!UnrealWindow.IsValid())
16 {
17 // Create FUnrealWindow
18 UnrealWindow = MakeShareable(new FUnrealWindow(Width, Height, Title));
19
20 // Setup on window closed event (user clicks Window's closed button)
22 UnrealWindow->GetSWindow()->SetOnWindowClosed(OnWindowClosedDelegate);
23
24 if (TextureRenderTarget)
25 {
26 SetupTextureRenderTarget(TextureRenderTarget);
27 }
28 }
29}
void SetupTextureRenderTarget(UTextureRenderTarget2D *TextureRenderTarget)
Definition: WindowActor.cpp:31
void OnWindowClosed(const TSharedRef< SWindow > &Window)
Definition: WindowActor.cpp:81

References OnWindowClosed(), OnWindowClosedDelegate, SetupTextureRenderTarget(), and UnrealWindow.

Member Data Documentation

◆ OnWindowClosedDelegate

FOnWindowClosed AWindowActor::OnWindowClosedDelegate

Definition at line 54 of file WindowActor.h.

Referenced by EndPlay(), and SetupWindow().

◆ UnrealWindow

TSharedPtr<FUnrealWindow> AWindowActor::UnrealWindow
private

The documentation for this class was generated from the following files: