using System.Collections.Generic; using TankAndHealerStudioAssets; using UnityEngine; using UnityEngine.InputSystem; namespace UltimateChatBoxExample { public class ChatStylesExample : MonoBehaviour { public UltimateChatBox chatBox; public string myUsername = "LocalPlayer"; public UltimateChatBox.ChatStyle customStyle = new UltimateChatBox.ChatStyle(); private List chatStyles = new List(); private int currentChatTypeIndex; private void Start() { chatStyles = new List(); chatStyles.Add(UltimateChatBoxStyles.boldUsername); chatStyles.Add(UltimateChatBoxStyles.whisperUsername); chatStyles.Add(UltimateChatBoxStyles.blueUsername); chatStyles.Add(UltimateChatBoxStyles.greenUsername); chatStyles.Add(customStyle); chatBox.OnInputFieldSubmitted += delegate(string message) { chatBox.RegisterChat(myUsername, message, chatStyles[currentChatTypeIndex]); }; } private void Update() { if (chatBox.IsEnabled && InputSystem.GetDevice().tabKey.wasPressedThisFrame) { currentChatTypeIndex++; if (currentChatTypeIndex >= chatStyles.Count) { currentChatTypeIndex = 0; } chatBox.ExtraImageColor = ((chatStyles[currentChatTypeIndex].usernameColor == Color.clear) ? Color.white : chatStyles[currentChatTypeIndex].usernameColor); } } } }