Skip to content

Commit

Permalink
Merge pull request #614 from starfi5h/pr-decouple
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomGamers authored Dec 14, 2023
2 parents 01ed3fb + 46f725e commit 19e319e
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private void Awake()
if (chatGo == null)
{
// Create chat window when there is no existing one
GameObject prefab = AssetLoader.AssetBundle.LoadAsset<GameObject>("Assets/Prefab/ChatV2.prefab");
GameObject prefab = AssetLoader.AssetBundle.LoadAsset<GameObject>("Assets/Prefab/ChatV2.prefab");
chatGo = Instantiate(prefab, parent, false);
chatGo.name = "Chat Window";

Expand All @@ -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<TranslucentImage>());
backgroundImage = backgroundGo.AddComponent<Image>();
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<TranslucentImage>());
backgroundImage = backgroundGo.AddComponent<Image>();
backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity);

backgroundGo = chatGo.transform.Find("Main/EmojiPicker/background").gameObject;
DestroyImmediate(backgroundGo.GetComponent<TranslucentImage>());
Image EmojiPickerbackground = backgroundGo.AddComponent<Image>();
EmojiPickerbackground.color = new Color(0f, 0f, 0f, 1f);
}
catch (Exception e)
{
Log.Error(e);
}
}

chatWindow = chatGo.transform.GetComponentInChildren<ChatWindow>();
Expand All @@ -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()
Expand Down

0 comments on commit 19e319e

Please sign in to comment.