Navigation
API > API/Runtime > API/Runtime/Engine
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.
| Name | UCanvasRenderTarget2D |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/Engine/CanvasRenderTarget2D.h |
| Include Path | #include "Engine/CanvasRenderTarget2D.h" |
Syntax
UCLASS (BlueprintType, Blueprintable, MinimalAPI)
class UCanvasRenderTarget2D : public UTextureRenderTarget2D
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UStreamableRenderAsset → UTexture → UTextureRenderTarget → UTextureRenderTarget2D → UCanvasRenderTarget2D
Implements Interfaces
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UCanvasRenderTarget2D
(
const FObjectInitializer& ObjectInitializer |
Engine/CanvasRenderTarget2D.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| OnCanvasRenderTargetUpdate | FOnCanvasRenderTargetUpdate | Called when this Canvas Render Target is asked to update its texture resource. | Engine/CanvasRenderTarget2D.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void FastUpdateResource() |
Don't delete the underlying resource if it already exists | Engine/CanvasRenderTarget2D.h | |
void GetSize
(
int32& Width, |
Gets a specific render target's size from the global map of canvas render targets. | Engine/CanvasRenderTarget2D.h |
|
virtual UWorld * GetWorld() |
Engine/CanvasRenderTarget2D.h | ||
void ReceiveUpdate
(
UCanvas* Canvas, |
Allows a Blueprint to implement how this Canvas Render Target 2D should be updated. | Engine/CanvasRenderTarget2D.h |
|
void SetSampleCount
(
ETextureRenderTargetSampleCount InSampleCount |
Engine/CanvasRenderTarget2D.h |
|
|
void SetShouldClearRenderTargetOnReceiveUpdate
(
bool bInShouldClearRenderTargetOnReceiveUpdate |
Engine/CanvasRenderTarget2D.h | ||
bool ShouldClearRenderTargetOnReceiveUpdate() |
Engine/CanvasRenderTarget2D.h |
Overridden from UTextureRenderTarget2D
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ETextureRenderTargetSampleCount GetSampleCount() |
Engine/CanvasRenderTarget2D.h |
|
Overridden from UTexture
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void UpdateResource () |
Updates the the canvas render target texture's resource. | Engine/CanvasRenderTarget2D.h |
|
virtual void UpdateResourceWithParams
(
EUpdateResourceFlags InFlags |
Creates a new resource for the texture, and updates any cached references to the resource. | Engine/CanvasRenderTarget2D.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool CanEditChange
(
const FProperty* InProperty |
Engine/CanvasRenderTarget2D.h | ||
virtual void PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
Engine/CanvasRenderTarget2D.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void OnSampleCountChanged() |
Engine/CanvasRenderTarget2D.h | ||
void RepaintCanvas() |
Engine/CanvasRenderTarget2D.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static UCanvasRenderTarget2D * CreateCanvasRenderTarget2D
(
UObject* WorldContextObject, |
Creates a new canvas render target and initializes it to the specified dimensions | Engine/CanvasRenderTarget2D.h |
|