Table of Contents

Class TexturedBox

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

A UI element that renders a textured rectangle. Supports coloring, transparency, texture alignment/scaling, and masking.

public class TexturedBox : HudElementBase, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent
Inheritance
TexturedBox
Implements
Derived
Inherited Members

Examples

The following example demonstrates the creation of a TexturedBox placed in the center of the screen using a built-in nebula texture from the Space Engineers skybox. It also places a second, blank TexturedBox on top of the first one.

// Material handle to a texture that is 256x256
public static readonly Material TestTex = new Material("RHFNebulaTest", new Vector2(256));

var nebulaBox = new TexturedBox(HudMain.HighDpiRoot)
{
    Material = TestTex,
    // This mode doesn't allow cropping or warping, making 
    // this box effectively 720x720pts
    MatAlignment = MaterialAlignment.FitAuto,
    Size = new Vector2(1280, 720)
};

var blankBox = new TexturedBox(nebulaBox)
{
    ParentAlignment = ParentAlignments.InnerBottom,
    Height = 50f,
    DimAlignment = DimAlignments.Width
};

This is the transparent material definition added to the .sbc file for the custom material used above.

<TransparentMaterial>
    <Id>
        <TypeId>TransparentMaterialDefinition</TypeId>
        <SubtypeId>RHFNebulaTest</SubtypeId>
    </Id>
    <AlphaMistingEnable>false</AlphaMistingEnable>
    <Texture>Textures\BackgroundCube\Prerender\Crab_Nebula.dds</Texture>
    <Reflectivity>0</Reflectivity>
</TransparentMaterial>

Remarks

This component serves as a minimal, non-interactive element for drawing textured quads based on Materials.

Normally, the element utilizes the Default material, creating a blank, tintable box. The visual behavior can be further customized using the MatAlignment property, which determines how the texture is scaled or cropped to fit the element's bounds (e.g., stretching to fit or preserving aspect ratio).

For details on custom material creation, see the Custom Textures article.

Constructors

TexturedBox()

public TexturedBox()

TexturedBox(HudParentBase)

public TexturedBox(HudParentBase parent)

Parameters

parent HudParentBase

Properties

Color

Gets or sets the tint color applied to the texture.

Note: Alpha affects opacity.

public Color Color { get; set; }

Property Value

Color

MatAlignment

Determines how the texture is scaled and positioned within the element's bounds (e.g., stretch to fit, preserve aspect ratio, etc.).

public MaterialAlignment MatAlignment { get; set; }

Property Value

MaterialAlignment

Material

Gets or sets the texture material applied to the background of this element.

public Material Material { get; set; }

Property Value

Material