Skip to content

Commit

Permalink
Merge pull request #12 from lexonegit/twitch-name-color
Browse files Browse the repository at this point in the history
Twitch name color behavior
  • Loading branch information
lexonegit authored Jan 24, 2023
2 parents b4b5e54 + 2a58144 commit edd61c6
Show file tree
Hide file tree
Showing 16 changed files with 1,638 additions and 96 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Unity Twitch Chat

This is a lightweight and efficient [Twitch.tv IRC](https://dev.twitch.tv/docs/irc/) client for Unity.<br>The primary goal is to be able to read and send chat messages as efficiently as possible.
This is a lightweight and efficient [Twitch.tv IRC](https://dev.twitch.tv/docs/irc/) client for Unity.

In short, this allows you to integrate Twitch Chat to your Unity projects.<br>The primary goal is to be able to read and send chat messages as efficiently as possible.


In short, this allows you to integrate Twitch Chat to your Unity projects.

## Chat message example
<img src="https://user-images.githubusercontent.com/18125997/210407885-b2c49e1e-4537-41e9-ad5b-2d8c4c8f1077.png">
Expand All @@ -25,7 +27,7 @@ In short, this allows you to integrate Twitch Chat to your Unity projects.

## Installation

- Open Unity Package Manager (Window -> Package Manager)
- Open Unity Package Manager <i>(Window -> Package Manager)</i>
- Click the `+` button in the top left corner
- Select `Add package from git URL...`
- Copy and paste the following URL:<br>
Expand All @@ -37,7 +39,7 @@ https://github.com/lexonegit/Unity-Twitch-Chat.git?path=/Unity-Twitch-Chat/Asset

## Quick start
1. Install the Unity package (see above)
2. Create a new empty GameObject and add the TwitchIRC component.
2. Create a new empty GameObject and add the `Twitch IRC` component.
3. In the inspector, set your Twitch authentication details (OAuth, username, channel)
You can generate an OAuth token at https://twitchapps.com/tmi/
OAuth and username are not needed if `Use Anonymous Login` is enabled.
Expand Down
5 changes: 4 additions & 1 deletion Unity-Twitch-Chat/Assets/ExampleProject/BoxController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using UnityEngine.UI;
using Lexone.UnityTwitchChat;

/// <summary>
/// This is an example script that shows some examples on how you could use the information from a Chatter object.
/// </summary>
public class BoxController : MonoBehaviour
{
public Transform ui;
Expand All @@ -23,7 +26,7 @@ public void Initialize(Chatter chatter)
// meaning that it only contains characters: a-z, A-Z, 0-9, _ (most fonts support these characters)
// If not "font-safe" then use login name instead, which should always be "font-safe"
nameText.text = chatter.IsDisplayNameFontSafe() ? chatter.tags.displayName : chatter.login;
//nameText.color = chatter.GetNameColor();
nameText.color = chatter.GetNameColor();

// Change box color to match chatter's primary badge
if (chatter.HasBadge("broadcaster"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ColorNormalizationTester : MonoBehaviour
{
private Text[] children;

private void Start()
{
children = GetComponentsInChildren<Text>();

foreach (Text text in children)
{
text.color = Lexone.UnityTwitchChat.ChatColors.NormalizeColor(text.color);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Unity-Twitch-Chat/Assets/ExampleProject/ListenerExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private void Start()
private void OnChatMessage(Chatter chatter)
{
Debug.Log($"<color=#fef83e><b>[CHAT LISTENER]</b></color> New chat message from {chatter.tags.displayName}");

if (spawnCount >= maxBoxes) // Max boxes reached
{
Debug.LogWarning("Max amount of boxes reached, not spawning any more");
Expand Down
8 changes: 8 additions & 0 deletions Unity-Twitch-Chat/Assets/ExampleProject/Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit edd61c6

Please sign in to comment.