Files
Continentis/Assets/OtherPlugins/Modern UI Pack/Scripts/UI Manager/UIManagerNotification.cs

59 lines
1.9 KiB
C#
Raw Normal View History

2026-03-20 11:56:50 -04:00
using TMPro;
using UnityEngine;
2025-10-03 00:02:43 -04:00
using UnityEngine.UI;
namespace Michsky.MUIP
{
[ExecuteInEditMode]
public class UIManagerNotification : MonoBehaviour
{
2026-03-20 11:56:50 -04:00
[Header("Settings")] [SerializeField] private UIManager UIManagerAsset;
[HideInInspector] public bool overrideColors;
[HideInInspector] public bool overrideFonts;
[Header("Resources")] [SerializeField] private Image background;
2025-10-03 00:02:43 -04:00
[SerializeField] private Image icon;
[SerializeField] private TextMeshProUGUI title;
[SerializeField] private TextMeshProUGUI description;
2026-03-20 11:56:50 -04:00
private void Awake()
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
if (UIManagerAsset == null) UIManagerAsset = Resources.Load<UIManager>("MUIP Manager");
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
enabled = true;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
if (!UIManagerAsset.enableDynamicUpdate)
2025-10-03 00:02:43 -04:00
{
UpdateNotification();
2026-03-20 11:56:50 -04:00
enabled = false;
2025-10-03 00:02:43 -04:00
}
}
2026-03-20 11:56:50 -04:00
private void Update()
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
if (UIManagerAsset == null) return;
if (UIManagerAsset.enableDynamicUpdate) UpdateNotification();
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
private void UpdateNotification()
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
if (!overrideColors)
2025-10-03 00:02:43 -04:00
{
background.color = UIManagerAsset.notificationBackgroundColor;
icon.color = UIManagerAsset.notificationIconColor;
title.color = UIManagerAsset.notificationTitleColor;
description.color = UIManagerAsset.notificationDescriptionColor;
}
2026-03-20 11:56:50 -04:00
if (!overrideFonts)
2025-10-03 00:02:43 -04:00
{
title.font = UIManagerAsset.notificationTitleFont;
title.fontSize = UIManagerAsset.notificationTitleFontSize;
description.font = UIManagerAsset.notificationDescriptionFont;
description.fontSize = UIManagerAsset.notificationDescriptionFontSize;
}
}
}
}