Steam Lobby Chat UI

Implement a simple lobby chat. With the Steam Lobby Chat UI component, you can connect standard Unity GUI elements for a quick, robust Lobby Chat.

Events

On Chat Message

public LobbyChatMsgEvent onChatMessage;

Invoked whenever a new chat message is received in the lobby. Provides the LobbyChatMsg object containing sender, message content, and message type.


Fields and Attributes

Max Messages

[SerializeField]
private int maxMessages = 200;

The maximum number of chat messages displayed at once. When this limit is reached, older messages are removed from the UI.

Chat Panel

[SerializeField]
private GameObject chatPanel;

The parent panel for the chat UI. Automatically shown or hidden based on whether a valid lobby exists.

Input Field

[SerializeField]
private TMPro.TMP_InputField inputField;

Text input is used to send chat messages.

Scroll View

[SerializeField]
private UnityEngine.UI.ScrollRect scrollView;

Scrollable container that holds chat messages.

Message Root

[SerializeField]
private Transform messageRoot;

Transform under which all chat message UI elements are instantiated.

My Chat Template

[SerializeField]
private GameObject myChatTemplate;

Template used for chat messages sent by the local user. This should implement the IChatMessage interface either with a custom script or by using the built-in Basic Chat Message component

Their Chat Template

[SerializeField]
private GameObject theirChatTemplate;

Template used for chat messages sent by other users.

Chat Messages

private readonly List<IChatMessage> chatMessages = new();

Internal list of currently displayed chat messages. Used to manage message count and scroll behaviour.


Functions

Clear

public void Clear()

Removes all chat messages from the UI and clears the chatMessages list.

Last updated