Class WorldTextRenderData
- Namespace
- Stride.CommunityToolkit.Rendering.Text
- Assembly
- Stride.CommunityToolkit.dll
Per-component state the world text renderer keeps between frames.
public class WorldTextRenderData
- Inheritance
-
WorldTextRenderData
Remarks
Holds the measured size of the text, which is needed to anchor it and to work out the scale that makes it Height tall. Measuring is far too expensive to repeat every frame for every label, and holding the result here rather than in a dictionary inside the renderer gives it a correct lifetime - the processor creates it with the component and drops it when the component goes away.
Constructors
WorldTextRenderData(WorldTextComponent)
Per-component state the world text renderer keeps between frames.
public WorldTextRenderData(WorldTextComponent component)
Parameters
componentWorldTextComponentThe component being drawn.
Remarks
Holds the measured size of the text, which is needed to anchor it and to work out the scale that makes it Height tall. Measuring is far too expensive to repeat every frame for every label, and holding the result here rather than in a dictionary inside the renderer gives it a correct lifetime - the processor creates it with the component and drops it when the component goes away.
Properties
Component
Gets the component being drawn.
public WorldTextComponent Component { get; }
Property Value
Entity
Gets the entity the component is attached to.
public Entity Entity { get; }
Property Value
Methods
GetMeasuredSize(SpriteBatch, SpriteFont)
Returns the size of the text in font pixels at FontSize, measuring only when the text, size or font changed.
public Vector2 GetMeasuredSize(SpriteBatch spriteBatch, SpriteFont font)
Parameters
spriteBatchSpriteBatchThe batch used to measure.
fontSpriteFontThe font the text will be drawn with.
Returns
- Vector2
The width and height of the text, in font pixels.
GetMeasuredSize(SpriteBatch, SpriteFont, float)
Returns the size of the text in font pixels at a given font size - the component's own size times the display's scale, when the renderer is following it - measuring only when the text, size or font changed.
public Vector2 GetMeasuredSize(SpriteBatch spriteBatch, SpriteFont font, float fontSize)
Parameters
spriteBatchSpriteBatchThe batch used to measure.
fontSpriteFontThe font the text will be drawn with.
fontSizefloatThe size the glyphs are rasterised at, in pixels.
Returns
- Vector2
The width and height of the text, in font pixels.