Skip to content

Commit

Permalink
Small changes to example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lexonegit committed Aug 22, 2024
1 parent 4a251d4 commit 126e78c
Show file tree
Hide file tree
Showing 3 changed files with 892 additions and 108 deletions.
12 changes: 8 additions & 4 deletions Unity-Twitch-Chat/Assets/ExampleProject/ListenerExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ public class ListenerExample : MonoBehaviour
public Chatter chatterObject; // Latest chatter object
public BoxController boxPrefab;
public int maxBoxes = 100;

private int spawnCount = 0;

private void Start()
{
// Add a listener for the IRC.OnChatMessage event
IRC.Instance.OnChatMessage += OnChatMessage;
}

private void OnChatMessage(Chatter chatter)
{
Debug.Log($"<color=#fef83e><b>[CHAT LISTENER]</b></color> New chat message from {chatter.tags.displayName}");
// Handle new chat messages...

Debug.Log($"<color=#fef83e><b>[LISTENER EXAMPLE]</b></color> New chat message from {chatter.tags.displayName}");

// Debug.Log($"Message content: {chatter.message}");

if (spawnCount >= maxBoxes) // Max boxes reached
if (spawnCount >= maxBoxes)
{
Debug.LogWarning("Max amount of boxes reached, not spawning any more");
Debug.LogWarning("Max amount of boxes reached!");
return;
}

Expand Down
Loading

0 comments on commit 126e78c

Please sign in to comment.