Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit c51c3f3

Browse files
committed
Revert "RegisterSafe before GetComponent + initialized needed variable."
This reverts commit 4b1156a.
1 parent a8fc20f commit c51c3f3

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

Notification/NotificationSystem.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ public static void SetupNotifications()
3131
{
3232
_hudContent = GameObject.Find("/UserInterface/UnscaledUI/HudContent_Old");
3333

34-
NotificationController.RegisterSafe();
34+
var notificationTransform = _hudContent.transform.Find("Notification(Clone)");
35+
if (notificationTransform != null)
36+
{
37+
//Notification system already initialized
38+
_notificationGO = notificationTransform.gameObject;
39+
_controllerInstance = _notificationGO.GetComponent<NotificationController>();
40+
41+
return;
42+
}
3543

3644
LoadAssets();
3745

46+
NotificationController.RegisterSafe();
47+
3848
MelonPreferences.CreateCategory("ReModCore", "ReMod.Core");
3949
NotificationAlpha = MelonPreferences.CreateEntry("ReModCore", "NotificationAlpha", .7f, "Notification Alpha", "Controls transparency of the notification system.");
4050
NotificationAlignment = MelonPreferences.CreateEntry("ReModCore", "NotificationAlignment", "centerMiddle", "Notification Alignment");
@@ -47,25 +57,6 @@ public static void SetupNotifications()
4757
if (_notificationPrefab == null)
4858
throw new Exception("NotificationSystem failed to load, prefab missing!");
4959

50-
/*
51-
* Horrible bandaid
52-
*/
53-
var notificationTransform = _hudContent.transform.Find("Notification(Clone)");
54-
if (notificationTransform != null)
55-
{
56-
//Notification system already initialized
57-
_notificationGO = notificationTransform.gameObject;
58-
_notificationRect = notificationTransform.GetComponent<RectTransform>();
59-
_controllerInstance = _notificationGO.GetComponent<NotificationController>();
60-
if (_controllerInstance == null) // The other mod that initialized the notification system isn't using ReMod.Core.Notification.NotificationController.
61-
{
62-
_controllerInstance = _notificationGO.AddComponent<NotificationController>(); // Add our own NotificationController, will cause odd visual bugs in the case of notifications from other mods overlapping.
63-
_controllerInstance.defaultSprite = DefaultIcon;
64-
UpdateNotificationAlignment(null, null);
65-
}
66-
return;
67-
}
68-
6960
//Instantiate prefab and let NotificationController setup!
7061
_notificationGO = Object.Instantiate(_notificationPrefab, _hudContent.transform);
7162
_controllerInstance = _notificationGO.AddComponent<NotificationController>();

0 commit comments

Comments
 (0)