Skip to content

Commit edd61c6

Browse files
authored
Merge pull request #12 from lexonegit/twitch-name-color
Twitch name color behavior
2 parents b4b5e54 + 2a58144 commit edd61c6

16 files changed

+1638
-96
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Unity Twitch Chat
22

3-
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.
3+
This is a lightweight and efficient [Twitch.tv IRC](https://dev.twitch.tv/docs/irc/) client for Unity.
4+
5+
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.
6+
47

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

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

2628
## Installation
2729

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

3840
## Quick start
3941
1. Install the Unity package (see above)
40-
2. Create a new empty GameObject and add the TwitchIRC component.
42+
2. Create a new empty GameObject and add the `Twitch IRC` component.
4143
3. In the inspector, set your Twitch authentication details (OAuth, username, channel)
4244
You can generate an OAuth token at https://twitchapps.com/tmi/
4345
OAuth and username are not needed if `Use Anonymous Login` is enabled.

Unity-Twitch-Chat/Assets/ExampleProject/BoxController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using UnityEngine.UI;
55
using Lexone.UnityTwitchChat;
66

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

2831
// Change box color to match chatter's primary badge
2932
if (chatter.HasBadge("broadcaster"))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
public class ColorNormalizationTester : MonoBehaviour
7+
{
8+
private Text[] children;
9+
10+
private void Start()
11+
{
12+
children = GetComponentsInChildren<Text>();
13+
14+
foreach (Text text in children)
15+
{
16+
text.color = Lexone.UnityTwitchChat.ChatColors.NormalizeColor(text.color);
17+
}
18+
}
19+
}

Unity-Twitch-Chat/Assets/ExampleProject/ColorNormalizationTester.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity-Twitch-Chat/Assets/ExampleProject/ListenerExample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private void Start()
1919
private void OnChatMessage(Chatter chatter)
2020
{
2121
Debug.Log($"<color=#fef83e><b>[CHAT LISTENER]</b></color> New chat message from {chatter.tags.displayName}");
22-
22+
2323
if (spawnCount >= maxBoxes) // Max boxes reached
2424
{
2525
Debug.LogWarning("Max amount of boxes reached, not spawning any more");

Unity-Twitch-Chat/Assets/ExampleProject/Scenes.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)