All feature managers are currently registered twice on startup.
This can cause Twitchmata to throw errors about duplicate items, such as trying to create 2 of each managed reward.
[TWITCHMATA] Could not create managed reward. Make sure a reward with this name doesn't already exist.
If you wish to convert an existing reward to a managed reward you must first delete the reward in Twitch's dashboard.
Cause
ConnectionManager.RegisterFeatureManager(FeatureManager manager) gets called twice for each FeatureManager.
The culprit here is GetComponents and GetComponentsInChildren being called on the same GameObject right after one another, which returns the same components twice.
Confusingly, GetComponentsInChildren returns the components on the children and also the object itself.
Problem
All feature managers are currently registered twice on startup.
This can cause Twitchmata to throw errors about duplicate items, such as trying to create 2 of each managed reward.
Cause
ConnectionManager.RegisterFeatureManager(FeatureManager manager)
gets called twice for each FeatureManager.The culprit here is
GetComponents
andGetComponentsInChildren
being called on the same GameObject right after one another, which returns the same components twice.Confusingly,
GetComponentsInChildren
returns the components on the children and also the object itself.From the Unity docs
Solution
The solution here is to simply remove the call to
GetComponents
and only useGetComponentsInChildren
.I've tested this in my own project and it works fine for me.
If only Unity had named it
GetComponentsInSelfAndChildren