Skip to main content

TextRendererBackground

A class in Root.Township, the global namespace.

Adds a quad behind a TextRenderer sized to its text plus a margin, and keeps it fitted when the text changes. Not set up on headless servers.

Constructors​

MemberWhat it is
TextRendererBackground()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

6 private and internal fields
MemberWhat it is
private Material androidMaterialMaterial meant for Android; the code here only uses pcMaterial.
private Vector2 marginExtra width and height around the text.
private static Mesh meshShared quad mesh used by every background.
private Material pcMaterialMaterial on the background quad.
private Transform rendererTransformTransform of the created background object.
private TextRenderer textRendererThe text renderer to fit.

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Subscribes to the text renderer's text updates (not on headless).
private void UpdateBackground()Creates the background quad if needed, then scales and centres it on the current text.