Table of Contents

Usage Instructions

Support

Thank you for buying our asset.

Unfortunately sometimes customers leave negative ratings and complain about things not working without contacting us so we can not help or fix the issue. We want to provide good support and have our customers having a great time developing their content, so:

If you happen to encounter any issues, please write an email to assets@firesplash.de and we will be happy to help!


Setup

Setting up the system is as simple as adding the component Twitch Integration Manager (aka TIM - Class Name Firesplash.UnityAssets.TwitchIntegration.TwitchIntegration) to a GameObject in your scene. You can then access it from your scripts. You can find all the methods under TwitchIntegration.PubSub and TwitchIntegration.Chat. There is a documented Example included with this asset. Refer to the code for an overview of how you can use it. In the following introduction, "twitch" is a reference to TIM.


Using PubSub

The PubSub part of this asset works the following way:

  1. Register an OnConnectionEstablished event to send the subscriptions using twitch.PubSub.OnConnectionEstablished.AddListener(() => { [...] });
  2. Within this event, subscribe to a topic using the specidif subscribe method. For example this one: twitch.PubSub.SubscribeToChannelPointsEvents(ChannelID, oAuthToken);
  3. To actually handle this event, we also have to handle the event which is raised, when a notifcation comes in. For our example we do this using these lines of code: twitch.PubSub.OnPointRewardEvent.AddListener((PubSubPointRewardEvent e) => { Debug.Log(e.Data.Redemption.RedeemedAt.ToString() + ": " + e.GetType().Name + ": Viewer " + e.Data.Redemption.User.DisplayName + " just redeemed " + e.Data.Redemption.Reward.Title + " for " + e.Data.Redemption.Reward.Cost + " Points."); });
  4. When everything is set up, we finally connect to the PubSub edge service: twitch.PubSub.Connect();

Using the Chat Integration

The Chat integration is quite simple. The Chat distinguished between Chat Messages and Commands so you can cleanly implement both. Just an example for this:

  1. Register your event for normal chat messages - if required: twitch.Chat.OnChatMessageReceived.AddListener((IRCMessage msg) => { [...] };
  2. Register your event for Commands - if required: twitch.Chat.OnChatCommandReceived.AddListener((IRCCommand com) => { [...] };
  3. Finally connect to the chat: twitch.Chat.Connect(channelName, oAuthToken);

Recent deprecations by tiwtch

Twitch has recently deprecated sending whispers and most other commands using IRC connection. This is a choice by twitch. The support for this will end mid february 2023. Read the official announcement here.

Correct Seat License Count

Officially you need to buy a seat license in the asset store for any unity user working with the asset. As this is not an editor asset but a "game asset" it is hard to determine how many seaty you need, right? We are always trying ot make our assets affordable and still rock solid. We ask our customers to be fair players and buy licenses according to the actual usage and revenue. Here is a guideline: ##For independent developers up to 5 team members working on your game (in total) and in compliance to the revenue terms of Unity "Free"... ...we allow using this asset with a single seat license for unlimited projects as long as you comply with the revenue terms for Unity "Free" (no matter if you are actually uisng Plus for some reason, Pro and Enterprise excluded). We do only count people working on the game (artists, developers, game designer, ...). If you hire IT specialists, marketing etc they do not count. ##For bigger independent dev teams, if you don't comply to the Unity Free license terms as a small team or if you are using Unity Pro or Enterprise... ...we ask you to buy one license per team member who works on your project (in Unity). ##For big studios and any enterprise licensee ...we assume you are making a lot of money with your games. Great! While the license requirements still are met with one license per unity user, we kindly request you to buy one seat per unity user or per project using our asset depending on what count is higher.

Frequently Asked Questions

How can I get that damn "OAuth token"?

Why am I getting an ERR_BADAUTH on PubSub while Chat is working fine?

Most likely you did not use your (numeric) Twitch Account ID to connect but your login name (which is fine for the chat but not working for PubSub). You need to use your channelID/userID for connecting to the PubSub service.

Where are incoming Raid/Host events? I can't find them in PubSub

Twitch does not send a (documented) PubSub Event on incoming Raids/Hosts so this is not possible. Fortunately it does send the event through the twitch chat. You can find the events in the Chat implementation: twitch.Chat.OnIncomingRaid and twitch.Chat.OnIncomingHost

When something goes wrong in the callbacks, the whole twitch integration stops working

This is normal behaviour. We do not catch Exceptions in the callbacks as this might make debugging a lot more complicated in some cases. We recommend to add try...catch blocks within your callback methods to catch unexpected exceptions when you go into production.