Skip to main content

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​

Action<MsgPresenter>

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​

Action<MsgPresenter>

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​

Color

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​

Sprite

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​

Color

text​

Gets or sets the main message text.

public string text { get; set; }

Property Value​

string

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​

NameTypeDescription
entryRuleEntryThe rule entry containing message data.
contextITypewriterContextThe Typewriter context (not used directly here, but may provide additional info).
ReleaseDelegateAction<MsgPresenter>Optional action to call when the message should be released.

Release()​

Immediately releases this message by invoking the ReleaseAction callback.

public void Release()
  • Fields
    • OnExpire
    • ReleaseAction
  • Properties
    • backgroundColor
    • displayName
    • icon
    • iconBackgroundColor
    • text
  • Methods
    • Init(RuleEntry, ITypewriterContext, Action<MsgPresenter>)
    • Release()