PAPER2UPaperSprite

Sprite Asset

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Paper2D

Header

/Engine/Plugins/2D/Paper2D/Source/Paper2D/Classes/PaperSprite.h

Include

#include "PaperSprite.h"

Syntax

UCLASS(BlueprintType, Meta=(DisplayThumbnail="true"))
class PAPER2UPaperSprite :
    public UObject,
    public IInterface_CollisionDataProvider,
    public ISlateTextureAtlasInterface

Remarks

Sprite Asset

Stores the data necessary to render a single 2D sprite (from a region of a texture) Can also contain collision shapes for the sprite.

Variables

Name Description

Protected variable UProperty Category, EditAnywhere, Meta assetregistrysearchable

TArray< TObject...

 

AdditionalSourceTextures

Additional source textures for other slots.

Protected variable UProperty Category, EditAnywhere BlueprintReadOnly

TObjectPtr< UMa...

 

AlternateMaterial

The alternate material to use on a sprite instance if not overridden (this is only used for Diced render geometry, and will be the opaque material in that case, slot 1)

Public variable UProperty

int32

 

AlternateMaterialSplitIndex

The point at which the alternate material takes over in the baked render data (or INDEX_NONE)

Protected variable UProperty Category, EditAnywhere assetregistrysearchable

TObjectPtr< cla...

 

AtlasGroup

Spritesheet group that this sprite belongs to.

Public variable UProperty

TArray< FVector...

 

BakedRenderData

Baked render data (triangle vertices, stored as XY UV tuples) XY is the XZ position in world space, relative to the pivot UV is normalized (0..1) There should always be a multiple of three elements in this array

Protected variable UProperty

FVector2D

 

BakedSourceDimension

Dimensions within BakedSourceTexture (in pixels)

Protected variable UProperty

TObjectPtr< UTe...

 

BakedSourceTexture

Protected variable UProperty

FVector2D

 

BakedSourceUV

Position within BakedSourceTexture (in pixels)

Public variable UProperty Category, EditAnywhere

TObjectPtr< cla...

 

BodySetup

Baked physics data.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

bool

 

bRotatedInSourceImage

This texture is rotated in the atlas.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

bool

 

bSnapPivotToPixelGrid

Should the pivot be snapped to a pixel boundary?

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

bool

 

bTrimmedInSourceImage

This texture is trimmed, consider the values above.

Protected variable UProperty Category, EditAnywhere

FSpriteGeometry...

 

CollisionGeometry

Custom collision geometry polygons (in texture space)

Protected variable UProperty Category, EditAnywhere

float

 

CollisionThickness

The extrusion thickness of collision geometry when using a 3D collision domain.

Protected variable UProperty Category, EditAnywhere

FVector2D

 

CustomPivotPoint

Custom pivot point (relative to the sprite rectangle)

Protected variable UProperty Category, EditAnywhere BlueprintReadOnly

TObjectPtr< UMa...

 

DefaultMaterial

The material to use on a sprite instance if not overridden (this is the default material when only one is being used, and is the translucent/masked material for Diced render geometry, slot 0)

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay, Meta

FVector2D

 

OriginInSourceImageBeforeTrimming

Origin within SourceImage, prior to atlasing.

Protected variable UProperty Category, EditAnywhere

TEnumAsByte< ES...

 

PivotMode

Pivot mode.

Protected variable UProperty Category, EditAnywhere, Meta

float

 

PixelsPerUnrealUnit

The scaling factor between pixels and Unreal units (cm) (e.g., 0.64 would make a 64 pixel wide sprite take up 100 cm)

Protected variable

TSoftObjectPtr<...

 

PreviousAtlasGroup

The previous spritesheet group this belonged to To make sure we remove ourselves from it if changed or nulled out

Protected variable UProperty Category, EditAnywhere

FSpriteGeometry...

 

RenderGeometry

Custom render geometry polygons (in texture space)

Protected variable UProperty Category, EditAnywhere

TArray< FPaperS...

 

Sockets

List of sockets on this sprite.

Protected variable UProperty Category, EditAnywhere assetregistrysearchable

FVector2D

 

SourceDimension

Dimensions within SourceTexture (in pixels)

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay, Meta

FVector2D

 

SourceImageDimensionBeforeTrimming

Dimensions of SourceImage.

Protected variable UProperty Category, EditAnywhere assetregistrysearchable

TSoftObjectPtr<...

 

SourceTexture

The source texture that the sprite comes from.

Protected variable UProperty Transient

TObjectPtr< UTe...

 

SourceTextureCacheNeverSerialized

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVector2D

 

SourceTextureDimension

Dimension of the texture when this sprite was created Used when the sprite is resized at some point

Protected variable UProperty Category, EditAnywhere assetregistrysearchable

FVector2D

 

SourceUV

Position within SourceTexture (in pixels)

Protected variable UProperty Category, EditAnywhere

TEnumAsByte< ES...

 

SpriteCollisionDomain

Collision domain (no collision, 2D, or 3D)

Constructors

Name Description

Public function

PAPER2UPaperSprite

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

void

 

BuildGeometryFromContours

(
    FSpriteGeometryCollection& GeomOwn...
)

Public function Const

FVector

 

ConvertPivotSpaceToTextureSpace

(
    FVector Input
)

Public function Const

FVector2D

 

ConvertPivotSpaceToTextureSpace

(
    FVector2D Input
)

Public function Const

FVector2D

 

ConvertTextureSpaceToPivotSpace

(
    FVector2D Input
)

Public function Const

FVector

 

ConvertTextureSpaceToPivotSpace

(
    FVector Input
)

Public function Const

FVector

 

ConvertTextureSpaceToWorldSpace

(
    const FVector2D& SourcePoint
)

World space WRT the sprite editor only

Public function Const

FVector2D

 

ConvertWorldSpaceDeltaToTextureSpace

(
    const FVector& WorldDelta,
    bool bIgnoreRotation
)

Public function Const

FVector2D

 

ConvertWorldSpaceToTextureSpace

(
    const FVector& WorldPoint
)

Public function

void

 

CreatePolygonFromBoundingBox

(
    FSpriteGeometryCollection& GeomOwn...,
    bool bUseTightBounds
)

Public function Static

void

 

ExtractRectsFromTexture

(
    UTexture2D* Texture,
    TArray< FIntRect >& OutRects
)

Public function

void

 

ExtractSourceRegionFromTexturePoint

(
    const FVector2D& Point
)

Public function Static

void

 

FindContours

(
    const FIntPoint& ScanPos,
    const FIntPoint& ScanSize,
    float AlphaThreshold,
    float Detail,
    UTexture2D* Texture,
    TArray< TArray< FIntPoint > >& Out...
)

Public function

FPaperSprite...

 

FindSocket

(
    FName SocketName
)

Search for a socket (.

Public function

void

 

FindTextureBoundingBox

(
    float AlphaThreshold,
    FVector2D& OutBoxPosition,
    FVector2D& OutBoxSize
)

Evaluates the SourceUV/SourceDimensons rectangle, finding the tightest bounds that still include all pixels with alpha above AlphaThreshold.

Public function Const

UMaterialInt...

 

GetAlternateMaterial()

Return the alternate material for this sprite.

Public function Const

const UPaper...

 

GetAtlasGroup()

Public function Const

void

 

GetBakedAdditionalSourceTextures

(
    FAdditionalSpriteTextureArray& Out...
)

Returns the list of additional source textures this should be rendered with.

Public function Const

UTexture2D &...

 

GetBakedTexture()

Returns the texture this should be rendered with.

Public function Const

float

 

GetCollisionThickness()

Returns the extrusion thickness of collision geometry when using a 3D collision domain.

Public function Const

UMaterialInt...

 

GetDefaultMaterial()

Return the default material for this sprite.

Public function Const

UMaterialInt...

 

GetMaterial

(
    int32 MaterialIndex
)

Returns either the default material (index 0) or alternate material (index 1)

Public function Const

int32

 

GetNumMaterials()

Returns the number of materials (1 or 2, depending on if there is alternate geometry)

Public function Const

FVector2D

 

GetOriginInSourceImageBeforeTrimming()

Returns the Origin within SourceImage, prior to atlasing.

Public function Const

ESpritePivot...

 

GetPivotMode

(
    FVector2D& OutCustomTextureSpacePi...
)

Public function Const

FVector2D

 

GetPivotPosition()

Returns the current pivot position in texture space.

Public function Const

FTransform

 

GetPivotToWorld()

Public function Const

float

 

GetPixelsPerUnrealUnit()

Return the scaling factor between pixels and Unreal units (cm)

Public function Const

FVector2D

 

GetRawPivotPosition()

Returns the raw pivot position (ignoring pixel snapping)

Public function Const

FBoxSphereBo...

 

GetRenderBounds()

Returns the render bounds of this sprite.

Public function Const

FVector2D

 

GetSourceImageDimensionBeforeTrimming()

Returns the Dimensions of SourceImage prior to trimming.

Public function Const

FVector2D

 

GetSourceSize()

Public function Const

UTexture2D &...

 

GetSourceTexture()

Public function Const

FVector2D

 

GetSourceUV()

Public function Const

ESpriteColli...

 

GetSpriteCollisionDomain()

Returns the collision domain (no collision, 2D, or 3D)

Public function Const

float

 

GetUnrealUnitsPerPixel()

Return the scaling factor between Unreal units (cm) and pixels.

Public function Const

bool

 

HasAnySockets()

Returns true if the sprite has any sockets.

Public function

void

 

InitializeSprite

(
    const FSpriteAssetInitParameters& ...,
    bool bRebuildData
)

Reinitializes this sprite (.

Public function Const

bool

 

IsRotatedInSourceImage()

This texture is rotated in the atlas.

Public function Const

bool

 

IsTrimmedInSourceImage()

Returns true if this sprite is trimmed from the original texture, meaning that the source image dimensions and origin in the source image may not be the same as the final results for the sprite (empty alpha=0 pixels were trimmed from the exterior region)

Public function

bool

 

NeedRescaleSpriteData()

Rescale properties to handle source texture size change.

Public function

void

 

OnObjectReimported

(
    UTexture2D* InObject
)

Called when an object is re-imported in the editor.

Public function Const

void

 

QuerySupportedSockets

Returns a list of all of the sockets.

Public function

void

 

RebuildCollisionData()

Public function

void

 

RebuildData()

This is a generic "rebuild all" function that calls RebuildCollisionData() and then RebuildRenderData().

Public function

void

 

RebuildRenderData()

Protected function

void

 

RefreshBakedData()

Public function

void

 

RemoveSocket

(
    FName SocketName
)

Removes the specified socket.

Public function

void

 

RescaleSpriteData

(
    UTexture2D* Texture
)

Rescale properties to handle source texture size change.

Public function

void

 

SetPivotMode

(
    ESpritePivotMode::Type PivotMode,
    FVector2D CustomTextureSpacePivot,
    bool bRebuildData
)

Public function

void

 

SetRotated

(
    bool bRotated,
    bool bRebuildData
)

Public function

void

 

SetTrim

(
    bool bTrimmed,
    const FVector2D& OriginInSourceIma...,
    const FVector2D& SourceImageDimens...,
    bool bRebuildData
)

Public function

void

 

ValidateSocketNames()

Make sure all socket names are valid All duplicate / empty names will be made unique

Overridden from UObject

Name Description

Public function Virtual Const

void

 

GetAssetRegistryTags

(
    TArray< FAssetRegistryTag >& OutTa...
)

Gathers a list of asset registry searchable tags which are name/value pairs with some type information This only needs to be implemented for asset objects

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from IInterface_CollisionDataProvider

Name Description

Public function Virtual Const

bool

 

ContainsPhysicsTriMeshData

(
    bool InUseAllTriData
)

Interface for checking if the implementing objects contains triangle mesh collision data

Public function Virtual

bool

 

GetPhysicsTriMeshData

(
    FTriMeshCollisionData* Collisi...,
    bool InUseAllTriData
)

Interface for retrieving triangle mesh collision data from the implementing object

Overridden from ISlateTextureAtlasInterface

Name Description

Public function Virtual Const

FSlateAtlasD...

 

GetSlateAtlasData()

Gets the atlas data to use when rendering with slate.

See Also

UPaperSpriteComponent