Class MsgPresenter
Controls the presentation of a single chat or notification message. Responsible for displaying icon, text, background colors, playing associated audio, and tracking optional lifetime expiration for auto-removal. This presenter only manages the visuals and behavior of an individual message, not the chat canvas or list of messages as a whole.
public class MsgPresenter : MonoBehaviour
Inheritance
Fields
OnExpire
Action invoked when the message expires (e.g., lifetime runs out).
[Tooltip("Callback invoked when the message expires.")]
public Action<MsgPresenter> OnExpire
Field Value
ReleaseAction
Action invoked when the message should be released back to an object pool or removed.
[Tooltip("Callback for releasing or cleaning up the message.")]
public Action<MsgPresenter> ReleaseAction
Field Value
Properties
backgroundColor
Gets or sets the color of the main message background. Alpha is forced to 1 for consistency.
public Color backgroundColor { get; set; }
Property Value
displayName
Gets or sets the display name text shown at the top of the message (e.g., sender's name).
public string displayName { get; set; }
Property Value
string
icon
Gets or sets the sprite for the icon, automatically handling Image or SVGImage types.
public Sprite icon { get; set; }
Property Value
iconBackgroundColor
Gets or sets the background color of the icon image. Alpha is forced to 1 for consistency.
public Color iconBackgroundColor { get; set; }
Property Value
Methods
Init(RuleEntry, ITypewriterContext, Action<MsgPresenter>)
Initializes this presenter with data from the specified RuleEntry, setting text, icon, colors, audio, and lifetime as applicable.
public void Init(RuleEntry entry, ITypewriterContext context, Action<MsgPresenter> ReleaseDelegate = null)
Parameters
| Name | Type | Description |
|---|---|---|
entry | RuleEntry | The rule entry containing message data. |
context | ITypewriterContext | The Typewriter context (not used directly here, but may provide additional info). |
ReleaseDelegate | Action<MsgPresenter> | Optional action to call when the message should be released. |
Release()
Immediately releases this message by invoking the ReleaseAction callback.
public void Release()