TextChat Class

Prefab for text chat.

Definition

Namespace: Alteruna.Multiplayer.Prefabs
Assembly: Alteruna.Doc (in Alteruna.Doc.dll) Version: 1.0.0+a1176e08a0b4a6bfd8fefeddde6163a16d29e5ab
C#
public class TextChat
Inheritance
Object    TextChat

Remarks

Example

Here we have an example adding a simple command to the text chat.
C#
   public class CommandPrintLine : ITextChatCommand
{
    public string Command { get; } = "printline";
    public string Description { get; } = "print a message to local chat.";
    public string Usage { get; } = "/printLine <msg>";
    public bool IsCheat { get; } = false;
    public bool IgnoreCase { get; } = true;

       // Register command
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
    public static void Init() => TextChatSynchronizable.Commands.Add(new CommandPrintLine());

    public string Execute(TextChatSynchronizable textChat, string[] args)
    {
        if (args.Length < 0)
        {
               // Log error to the chat and return an empty response
            textChat.LogError("No message");
            return null;
        }

           // Join arguments as a singular string and return it to log it. 
        return string.Join(" ", args);
    }
}

Methods

SendChatMessage Send a chat message.

Fields

AllowCheats Allow cheats in the chat default state.
AllowCommands Allow commands in the chat.
AllowHostToToggleCheats Allow a host to enable cheats.
BoldNames Make the names bold in the chat.
ChatBuffer Change max number of buffered chat lines
GetUserColor Function for getting the user color from user id.
LogErrors Log Unity errors in the chat.
LogLocalOnSend Log local messages when being sent.
LogSystemMessages Log system messages in the chat.
TextChatUpdate Text updated event.
UseRichText Use rich text in the chat.
UseTimeStamps Sort messages based on senders timestamp.

See Also