reckfellENGINE

TextureRect

UI texture with separate sizing and display rules.

On this page
class TextureRectReckfellSharpInherits Control

TextureRect draws a Texture2D within a Control. Two settings solve different problems: ExpandMode defines intrinsic minimum size; StretchMode defines drawing within the allocated rectangle. Changing StretchMode does not automatically permit shrinking below the texture’s dimensions.

For an image in a parent-sized area, normally set ExpandMode = IgnoreSize and StretchMode = KeepAspectCentered. The first removes the texture-derived minimum; the second fits and centers without changing aspect ratio. The container, anchors or Size still define the area. CustomMinimumSize and parent layout constraints remain active.

Scale stretches both axes and can distort proportions. Keep draws at original size from the area’s origin; KeepCentered centers without scaling, so the image can overflow. KeepAspect fits from the origin; KeepAspectCentered also centers. KeepAspectCovered fills proportionally using a central region of the source texture. Tile repeats the image; AtlasTexture with nonzero Margin is unsupported in this mode.

KeepSize is the default ExpandMode: minimum equals texture size. IgnoreSize returns zero intrinsic minimum. FitWidth uses current height as minimum width; FitWidthProportional multiplies it by texture width/height. FitHeight and FitHeightProportional do the reverse. For example, an 80 × 40 texture and control height 30 produce minimum width 30 with FitWidth and 60 with FitWidthProportional. These are minimum-size rules rather than commands to change Size immediately.

Do not combine FitWidthProportional/FitHeightProportional with a parent AspectRatioContainer: that combination is skipped during layout. Use IgnoreSize and manage proportions through the container or StretchMode instead.

FlipH/FlipV mirror drawing without editing the source resource. Texture is shared: changes to the resource itself can affect other elements. Texture = null draws nothing while explicit Control constraints remain. MouseFilter defaults to Pass; use Ignore for a purely decorative image over interactive UI.

General container rules.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

TextureRectConstructor
# TextureRect
C#
public TextureRect();

Creates a Control without a texture: ExpandMode = KeepSize, StretchMode = Scale, flips off, MouseFilter = Pass.

Properties5

ExpandModeProperty
# ExpandMode
C#
public TextureRect.ExpandModeEnum ExpandMode { get; set; }

Intrinsic minimum-size rule, default KeepSize. IgnoreSize removes the texture minimum. FitWidth/FitHeight depend on the current opposite-axis size; proportional variants also use texture aspect ratio. Does not select drawing behavior.

FlipHProperty
# FlipH
C#
public bool FlipH { get; set; }

Horizontal drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

FlipVProperty
# FlipV
C#
public bool FlipV { get; set; }

Vertical drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

StretchModeProperty
# StretchMode
C#
public TextureRect.StretchModeEnum StretchMode { get; set; }

Drawing mode within the allocated area, default Scale. KeepAspectCentered fits without distortion; KeepAspectCovered fills using a central crop. Does not change ExpandMode’s intrinsic minimum. Tile with nonzero-margin AtlasTexture is unsupported.

TextureProperty
# Texture
C#
public Texture2D Texture { get; set; }

Shared Texture2D reference; null disables drawing. Replacement refreshes minimum size and drawing without removing CustomMinimumSize. Resource changes are also observed.

Methods10

GetExpandModeTextureRect.ExpandModeEnum
# GetExpandMode
C#
public TextureRect.ExpandModeEnum GetExpandMode();

Intrinsic minimum-size rule, default KeepSize. IgnoreSize removes the texture minimum. FitWidth/FitHeight depend on the current opposite-axis size; proportional variants also use texture aspect ratio. Does not select drawing behavior.

Returns TextureRect.ExpandModeEnum

Current stored setting.

GetStretchModeTextureRect.StretchModeEnum
# GetStretchMode
C#
public TextureRect.StretchModeEnum GetStretchMode();

Drawing mode within the allocated area, default Scale. KeepAspectCentered fits without distortion; KeepAspectCovered fills using a central crop. Does not change ExpandMode’s intrinsic minimum. Tile with nonzero-margin AtlasTexture is unsupported.

Returns TextureRect.StretchModeEnum

Current stored setting.

GetTextureTexture2D
# GetTexture
C#
public Texture2D GetTexture();

Shared Texture2D reference; null disables drawing. Replacement refreshes minimum size and drawing without removing CustomMinimumSize. Resource changes are also observed.

Returns Texture2D

Current shared Texture2D reference, or null.

IsFlippedHbool
# IsFlippedH
C#
public bool IsFlippedH();

Horizontal drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

Returns bool

Current stored setting.

IsFlippedVbool
# IsFlippedV
C#
public bool IsFlippedV();

Vertical drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

Returns bool

Current stored setting.

SetExpandModevoid
# SetExpandMode
C#
public void SetExpandMode(TextureRect.ExpandModeEnum expandMode);

Intrinsic minimum-size rule, default KeepSize. IgnoreSize removes the texture minimum. FitWidth/FitHeight depend on the current opposite-axis size; proportional variants also use texture aspect ratio. Does not select drawing behavior.

Parameters
NameTypeDefault
expandModeTextureRect.ExpandModeEnum—
expandMode

Intrinsic minimum-size rule, default KeepSize. IgnoreSize removes the texture minimum. FitWidth/FitHeight depend on the current opposite-axis size; proportional variants also use texture aspect ratio. Does not select drawing behavior.

SetFlipHvoid
# SetFlipH
C#
public void SetFlipH(bool enable);

Horizontal drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

Parameters
NameTypeDefault
enablebool—
enable

Horizontal drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

SetFlipVvoid
# SetFlipV
C#
public void SetFlipV(bool enable);

Vertical drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

Parameters
NameTypeDefault
enablebool—
enable

Vertical drawing flip, default false. Does not change source Texture2D, Control size or intrinsic minimum.

SetStretchModevoid
# SetStretchMode
C#
public void SetStretchMode(TextureRect.StretchModeEnum stretchMode);

Drawing mode within the allocated area, default Scale. KeepAspectCentered fits without distortion; KeepAspectCovered fills using a central crop. Does not change ExpandMode’s intrinsic minimum. Tile with nonzero-margin AtlasTexture is unsupported.

Parameters
NameTypeDefault
stretchModeTextureRect.StretchModeEnum—
stretchMode

Drawing mode within the allocated area, default Scale. KeepAspectCentered fits without distortion; KeepAspectCovered fills using a central crop. Does not change ExpandMode’s intrinsic minimum. Tile with nonzero-margin AtlasTexture is unsupported.

SetTexturevoid
# SetTexture
C#
public void SetTexture(Texture2D texture);

Shared Texture2D reference; null disables drawing. Replacement refreshes minimum size and drawing without removing CustomMinimumSize. Resource changes are also observed.

Parameters
NameTypeDefault
textureTexture2D—
texture

Shared Texture2D, or null to clear drawing.

TextureRect.ExpandModeEnum

ValueDescription
FitHeight = 4

The width of the texture will be ignored. Minimum height will be equal to the current width. Useful for vertical layouts, e.g. inside VBoxContainer.

FitHeightProportional = 5

Same as TextureRect.ExpandModeEnum.FitHeight, but keeps texture's aspect ratio.

FitWidth = 2

The height of the texture will be ignored. Minimum width will be equal to the current height. Useful for horizontal layouts, e.g. inside HBoxContainer.

FitWidthProportional = 3

Same as TextureRect.ExpandModeEnum.FitWidth, but keeps texture's aspect ratio.

IgnoreSize = 1

The size of the texture won't be considered for minimum size calculation, so the TextureRect can be shrunk down past the texture size.

KeepSize = 0

The minimum size will be equal to texture size, i.e. TextureRect can't be smaller than the texture.

TextureRect.StretchModeEnum

ValueDescription
Keep = 2

The texture keeps its original size and stays in the bounding rectangle's top-left corner.

KeepAspect = 4

Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.

KeepAspectCentered = 5

Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.

KeepAspectCovered = 6

Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.

KeepCentered = 3

The texture keeps its original size and stays centered in the node's bounding rectangle.

Scale = 0

Scale to fit the node's bounding rectangle.

Tile = 1

Tile inside the node's bounding rectangle. Note: TextureRect.StretchModeEnum.Tile mode is not supported for TextureRect.Texture set to an AtlasTexture with non-zero AtlasTexture.Margin.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.