UCanvasRenderTarget2D

CanvasRenderTarget2D is 2D render target which exposes a Canvas interface to allow you to draw elements onto it directly.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/CanvasRenderTarget2D.h

Include

#include "Engine/CanvasRenderTarget2D.h"

Syntax

class UCanvasRenderTarget2D : public UTextureRenderTarget2D

Remarks

CanvasRenderTarget2D is 2D render target which exposes a Canvas interface to allow you to draw elements onto it directly. Use CreateCanvasRenderTarget2D() to create a render target texture by unique name, then bind a function to the OnCanvasRenderTargetUpdate delegate which will be called when the render target is updated. If you need to repaint your canvas every single frame, simply call UpdateResource() on it from a Tick function. Also, remember to hold onto your new canvas render target with a reference so that it doesn't get garbage collected.

Variables

Name Description

Protected variable

bool

 

bShouldClearRenderTargetOnReceiveUpdate

If true, clear the render target to green whenever OnReceiveUpdate() is called.

Public variable

FOnCanvasRender...

 

OnCanvasRenderTargetUpdate

Called when this Canvas Render Target is asked to update its texture resource.

Protected variable

TWeakObjectPtr<...

 

World

The world this render target will be used with

Constructors

Name Description

Public function

UCanvasRenderTarget2D

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Static

UCanvasRende...

 

CreateCanvasRenderTarget2D

(
    UObject* WorldContextObject,
    TSubclassOf< UCanvasRenderTarget2D ...,
    int32 Width,
    int32 Height
)

Creates a new canvas render target and initializes it to the specified dimensions

Public function

void

 

FastUpdateResource()

Don't delete the underlying resource if it already exists

Public function

void

 

GetSize

(
    int32& Width,
    int32& Height
)

Gets a specific render target's size from the global map of canvas render targets.

Public function Virtual Const

UWorld *

 

GetWorld()

Public function

void

 

ReceiveUpdate

(
    UCanvas* Canvas,
    int32 Width,
    int32 Height
)

Allows a Blueprint to implement how this Canvas Render Target 2D should be updated.

Protected function

void

 

RepaintCanvas()

Public function

void

 

SetShouldClearRenderTargetOnReceiveUpdate

(
    bool bInShouldClearRenderTargetOnRe...
)

Public function Const

bool

 

ShouldClearRenderTargetOnReceiveUpdate()

Overridden from UTexture

Name Description

Public function Virtual

void

 

UpdateResource()

Updates the the canvas render target texture's resource.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback