ChatMessageLine
UI component that renders a single chat message. Wraps a TextMeshProUGUI component and displays a ChatMessage using its ToString() representation. Used by the chat scroll rect to populate the message display area.
Definition
Namespace: Paragon.Townskeep.ChatSystem.HUD
Assembly: Townskeep.dll
public class ChatMessageLine : ParagonUIBehaviourInheritance: SerializedMonoBehaviour → ParagonBehaviour → ParagonUIBehaviour → ChatMessageLine
Remarks
ChatMessageLine is a lightweight display component — it holds a reference to a ChatMessage and renders it via TextMeshProUGUI. The HEIGHT constant defines the fixed height of each line element, used by the scroll rect for layout calculations.
The LineCount property returns the number of visible lines as configured on the TextMeshProUGUI component (via maxVisibleLines), which is useful for calculating the total scroll area needed.
Quick Lookup
Display a message
messageLine.SetMessage(chatMessage)
Clear the display
messageLine.ClearMessage()
Get line height
ChatMessageLine.HEIGHT (constant: 20f)
Get visible line count
messageLine.LineCount
Properties
LineCount
The maximum number of visible text lines in the TextMeshProUGUI component. Returns text.maxVisibleLines.
Methods
SetMessage
Displays a chat message. Stores the message reference and sets the text component to message.ToString().
message
ChatMessage
The message to display
ClearMessage
Resets the line to an empty state. Sets the stored message to ChatMessage.Empty and clears the text component.
Constants
HEIGHT
The fixed height (in pixels) of a single message line element. Used by the scroll rect for layout calculations.
Component Requirements
The ChatMessageLine GameObject must have a TextMeshProUGUI component on it (not on a child — GetComponent is used, not GetComponentInChildren).
Common Pitfalls
TextMeshProUGUI must be on the same GameObject
GetComponent<TextMeshProUGUI>() is called in Awake(). The text component must be on the same GameObject as ChatMessageLine, not a child.
HEIGHT is a compile-time constant
HEIGHT is const float, not configurable per-instance. If message lines have varying heights at runtime, the scroll rect layout may not calculate correctly.
See Also
Last updated