public IEnumerator UpdateEmoteMaterials(TwitchChatTester chat, TwitchChatTester.TwitchChatUpdate chatUpdate)
    {
        List <EmoteMaterial> list;
        var newList = new List <EmoteMaterial>();

        lock (ActiveEmoteLocker)
        {
            // Generate a list of Materials no longer being used
            var rem = (from mat in _activeEmoteMaterials where !chatUpdate.EmoteIds.Contains(mat.Id) select mat.Id).ToList();
            // Remove materials that are no longer being used
            foreach (var r in rem)
            {
                for (var i = 0; i < _activeEmoteMaterials.Count; i++)
                {
                    if (_activeEmoteMaterials[i].Id != r)
                    {
                        continue;
                    }
                    //Debug.Log("Not using " + _activeEmoteMaterials[i].Id);
                    _activeEmoteMaterials.RemoveAt(i);
                    break;
                }
            }
            list = _activeEmoteMaterials.ToArray().ToList();
            // Add materials that are now being used
            foreach (var mat in (from newId in chatUpdate.EmoteIds.ToList().Distinct() let found = list.Any(existing => existing.Id == newId) where !found select newId).Select(newId => new EmoteMaterial(newId, GenerateEmoteMaterial())))
            {
                _activeEmoteMaterials.Add(mat);
                newList.Add(mat);
            }
        }

        foreach (var mat in newList)
        {
            yield return(StartCoroutine(LoadEmote(mat)));

            list.Add(mat);
        }

        chat.SetChatMessages(chatUpdate, list.ToArray());
    }
 private Texture2D GetMaterialTexture()
 {
     return((Texture2D)(BackgroundMaterial.mainTexture ?? (BackgroundMaterial.mainTexture = TwitchChatTester.GenerateBaseTexture())));
 }
 public void Awake()
 {
     _instance = this;
     GenChatTexts();
 }
Пример #4
0
 public void Awake()
 {
     _instance = this;
 }