diff --git a/NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs b/NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs index 16def4746..a4b292714 100644 --- a/NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs +++ b/NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs @@ -23,7 +23,7 @@ private void Awake() if (chatGo == null) { // Create chat window when there is no existing one - GameObject prefab = AssetLoader.AssetBundle.LoadAsset("Assets/Prefab/ChatV2.prefab"); + GameObject prefab = AssetLoader.AssetBundle.LoadAsset("Assets/Prefab/ChatV2.prefab"); chatGo = Instantiate(prefab, parent, false); chatGo.name = "Chat Window"; @@ -36,11 +36,29 @@ private void Awake() trans.sizeDelta = defaultSize; trans.anchoredPosition = defaultPos; - // TODO: Fix ChatV2.prefab to get rid of warnings - GameObject backgroundGo = chatGo.transform.Find("Main/background").gameObject; - DestroyImmediate(backgroundGo.GetComponent()); - backgroundImage = backgroundGo.AddComponent(); - backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity); + try + { + // TODO: Fix ChatV2.prefab to get rid of warnings + Component removeComponent = chatGo.GetComponent("CommonAPI.MaterialFixer"); + if (removeComponent != null) + { + Destroy(removeComponent); + } + + GameObject backgroundGo = chatGo.transform.Find("Main/background").gameObject; + DestroyImmediate(backgroundGo.GetComponent()); + backgroundImage = backgroundGo.AddComponent(); + backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity); + + backgroundGo = chatGo.transform.Find("Main/EmojiPicker/background").gameObject; + DestroyImmediate(backgroundGo.GetComponent()); + Image EmojiPickerbackground = backgroundGo.AddComponent(); + EmojiPickerbackground.color = new Color(0f, 0f, 0f, 1f); + } + catch (Exception e) + { + Log.Error(e); + } } chatWindow = chatGo.transform.GetComponentInChildren(); @@ -64,7 +82,10 @@ public static void UpdateChatPosition() RectTransform trans = (RectTransform)Instance.chatWindow.transform; trans.anchoredPosition = defaultPos; trans.sizeDelta = defaultSize; - Instance.backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity); + if (Instance.backgroundImage != null) + { + Instance.backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity); + } } void Update()