Exemple #1
0
 private void Instance_OnConfigChanged(ChatConfig obj)
 {
     UpdateChatUI();
 }
Exemple #2
0
        private IEnumerator Start()
        {
            DontDestroyOnLoad(this.gameObject);
            this._chatConfig = ChatConfig.instance;
            yield return(new WaitWhile(() => !ESCFontManager.instance.IsInitialized));

            this.SetupScreens();
            foreach (var msg in this._messages.ToArray())
            {
                msg.Text.SetAllDirty();
                if (msg.SubTextEnabled)
                {
                    msg.SubText.SetAllDirty();
                }
            }
            (this.transform as RectTransform).pivot = new Vector2(0.5f, 0f);
            this.TextPool = new ObjectMemoryComponentPool <EnhancedTextMeshProUGUIWithBackground>(64,
                                                                                                  constructor: () =>
            {
                var go = new GameObject(nameof(EnhancedTextMeshProUGUIWithBackground), typeof(EnhancedTextMeshProUGUIWithBackground));
                DontDestroyOnLoad(go);
                go.SetActive(false);
                var msg = go.GetComponent <EnhancedTextMeshProUGUIWithBackground>();
                msg.Text.enableWordWrapping            = true;
                msg.Text.autoSizeTextContainer         = false;
                msg.SubText.enableWordWrapping         = true;
                msg.SubText.autoSizeTextContainer      = false;
                (msg.transform as RectTransform).pivot = new Vector2(0.5f, 0);
                msg.transform.SetParent(this._chatContainer.transform, false);
                this.UpdateMessage(msg);
                return(msg);
            },
                                                                                                  onFree: (msg) =>
            {
                try {
                    msg.gameObject.SetActive(false);
                    (msg.transform as RectTransform).localPosition = Vector3.zero;
                    msg.OnLatePreRenderRebuildComplete            -= this.OnRenderRebuildComplete;
                    msg.HighlightEnabled    = false;
                    msg.AccentEnabled       = false;
                    msg.SubTextEnabled      = false;
                    msg.Text.text           = "";
                    msg.Text.ChatMessage    = null;
                    msg.SubText.text        = "";
                    msg.SubText.ChatMessage = null;
                    msg.Text.ClearImages();
                    msg.SubText.ClearImages();
                }
                catch (Exception ex) {
                    Logger.Error($"An exception occurred while trying to free CustomText object. {ex.ToString()}");
                }
            }
                                                                                                  );
            ChatConfig.instance.OnConfigChanged += this.Instance_OnConfigChanged;
            BSEvents.menuSceneActive            += this.BSEvents_menuSceneActive;
            BSEvents.gameSceneActive            += this.BSEvents_gameSceneActive;

            yield return(new WaitWhile(() => this._chatScreen == null));

            while (_backupMessageQueue.TryDequeue(out var msg))
            {
                var task = this.OnTextMessageReceived(msg.Value, msg.Key).GetAwaiter();
                yield return(new WaitWhile(() => !task.IsCompleted));
            }
        }