public void Initialize(Chatter chatter) { gameObject.name = chatter.login; // If chatter's display name is "font safe" then use it. Otherwise use login name. // Login name is always lowercase and can only contain characters: a-z, A-Z, 0-9, _ // fighterName.text = chatter.IsDisplayNameFontSafe() ? chatter.tags.displayName : chatter.login; fighterName.color = ColorUtility.TryParseHtmlString(chatter.tags.colorHex, out var colour) ? colour : Color.white; // Change box color // if (chatter.HasBadge("moderator")) { spriteRenderer.color = Color.green; // Green box if chatter has moderator badge } else if (chatter.HasBadge("vip")) { spriteRenderer.color = Color.magenta; // Magenta box if chatter has VIP badge } else if (chatter.HasBadge("subscriber")) { spriteRenderer.color = Color.red; // Red box if chatter has subscriber badge } // Start jumping StartCoroutine(Jump()); }
public void Initialize(Chatter chatter) { // Set chatter's name // // If chatter's display name is "font safe" then use it. Otherwise use login name. // Login name is always lowercase and can only contain characters: a-z, A-Z, 0-9, _ // nameText.text = chatter.IsDisplayNameFontSafe() ? chatter.tags.displayName : chatter.login; // Change box color // if (chatter.HasBadge("moderator")) { spriteRenderer.color = Color.green; // Green box if chatter has moderator badge } else if (chatter.HasBadge("vip")) { spriteRenderer.color = Color.magenta; // Magenta box if chatter has VIP badge } else if (chatter.HasBadge("subscriber")) { spriteRenderer.color = Color.red; // Red box if chatter has subscriber badge } // Detach name canvas from parent so that it doesn't rotate canvasTransform.SetParent(null); // Start jumping StartCoroutine(Jump()); }
// This gets called whenever a new chat message is received public void NewMessage(Chatter chatter) { Debug.Log( "<color=cyan>New chatter object received!</color>" + " Chatter's name: " + chatter.tags.displayName + " Chatter's message: " + chatter.message); // Here are some examples on how you could use the chatter objects... if (chatter.tags.displayName == "Lexone") { Debug.Log("Chat message was sent by Lexone!"); } if (chatter.HasBadge("subscriber")) { Debug.Log("Chat message sender is a subscriber"); } if (chatter.HasBadge("moderator")) { Debug.Log("Chat message sender is a channel moderator"); } if (chatter.MessageContainsEmote("25")) //25 = Kappa emote ID { Debug.Log("Chat message contained the Kappa emote"); } if (chatter.message == "!join") { Debug.Log(chatter.tags.displayName + " said !join"); } // Get chatter's name color (RGBA Format) // Color nameColor = chatter.GetRGBAColor(); // Check if chatter's display name is "font safe" // // Most fonts don't support unusual characters // If that's the case then you could use their login name instead (chatter.login) or use a fallback font // Login name is always lowercase and can only contain characters: a-z, A-Z, 0-9, _ if (chatter.IsDisplayNameFontSafe()) { Debug.Log("Chatter's displayName is font-safe (only characters: a-z, A-Z, 0-9, _)"); } // Save latest chatter object // This is just to show how the Chatter object looks like inside the Inspector latestChatter = chatter; }
// This gets called whenever a new chat message appears public void NewMessage(Chatter chatter) { Debug.Log("New chatter object received! " + chatter.tags.displayName); // Some examples on how you could use the chatter objects if (chatter.tags.displayName == "Lexone") { Debug.Log("Chat message was sent by Lexone!"); } if (chatter.HasBadge("subscriber")) { Debug.Log("Chat message sender is a subscriber"); } if (chatter.HasBadge("moderator")) { Debug.Log("Chat message sender is a channel moderator"); } if (chatter.MessageContainsEmote("25")) //25 = Kappa emote ID { Debug.Log("Chat message contained the Kappa emote"); } if (chatter.message == "!join") { Debug.Log(chatter.tags.displayName + " said !join"); } // Get chatter's name color (RGBA Format) // Color nameColor = chatter.GetRGBAColor(); // Check chatter's display name for unusual characters // // This can be useful to check for because most fonts don't support unusual characters // If that's the case then you could use their login name instead (chatter.login) or use a fallback font // Login name is always lowercase and can only contain characters: a-z, A-Z, 0-9, _ // if (chatter.CheckDisplayName()) { Debug.Log("Chatter's displayName contains characters other than a-z, A-Z, 0-9, _"); } latestChatter = chatter; }