Skip to content

Commit 1d77604

Browse files
committed
Update hook to be settable from static context
1 parent 79ae3f6 commit 1d77604

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Runtime/Notifications.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public class Notifications : MonoBehaviour
3636
[SerializeField] private GameObject notificationPrefab;
3737
#pragma warning restore CS0649
3838

39-
public Func<string, string> TranslationFunction { set; private get; }
39+
public static Func<string, string> TranslationFunction
40+
{
41+
set => instance.translationFunction = value;
42+
}
43+
44+
private Func<string, string> translationFunction;
4045

4146
// Singleton design, assigned in Awake().
4247
private static Notifications instance;
@@ -233,9 +238,9 @@ private void SendNotification(Notification notification)
233238
var rect = notificationGameObject.GetComponent<RectTransform>();
234239

235240
var message = notification.Message;
236-
if (TranslationFunction != null)
241+
if (translationFunction != null)
237242
{
238-
message = TranslationFunction(message);
243+
message = translationFunction(message);
239244
}
240245
notificationGameObject.GetComponent<NotificationUI>().SetUp(message, GetColor(notification.Type), notification.OnClickEvent);
241246

0 commit comments

Comments
 (0)