Documentation for the Unity C# Library
Loading...
Searching...
No Matches
ErrorMessagePopup.cs
Go to the documentation of this file.
1using System;
2using TMPro;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class ErrorMessagePopup : MonoBehaviour
7{
8 [SerializeField] private Button _closeButton;
9 [SerializeField] private Transform _root;
10 [SerializeField] private TextMeshProUGUI _errorMessageText;
12 public event Action CloseButtonClicked;
13
14 private void Start()
15 {
16 _root.gameObject.SetActive(false);
17 }
18
19 private void OnEnable()
20 {
21 _closeButton.onClick.AddListener(OnCloseButtonClicked);
22 }
24 private void OnDisable()
25 {
26 _closeButton.onClick.RemoveListener(OnCloseButtonClicked);
27 }
29 private void OnCloseButtonClicked()
30 {
31 _root.gameObject.SetActive(false);
32
34 }
35
36 public void ShowErrorMessage(string text)
37 {
38 _root.gameObject.SetActive(true);
39
40 _errorMessageText.text = text;
41 }
42}
void ShowErrorMessage(string text)
Button _closeButton
[SerializeField]
TextMeshProUGUI _errorMessageText
[SerializeField]
Transform _root
[SerializeField]