1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using UnityEngine ;
3
- using UnityEngine . UI ;
4
4
using TMPro ;
5
- using Unity . Multiplayer . Samples . BossRoom . Shared . Infrastructure ;
6
- using Unity . Multiplayer . Samples . BossRoom . Shared . Net . UnityServices . Infrastructure ;
7
- using UnityEngine . SceneManagement ;
8
5
9
6
namespace Unity . Multiplayer . Samples . BossRoom . Visual
10
7
{
@@ -13,11 +10,25 @@ namespace Unity.Multiplayer.Samples.BossRoom.Visual
13
10
/// </summary>
14
11
public class PopupPanel : MonoBehaviour
15
12
{
13
+ struct PopupPanelData
14
+ {
15
+ public string TitleText ;
16
+ public string MainText ;
17
+
18
+ public PopupPanelData ( string titleText , string mainText )
19
+ {
20
+ TitleText = titleText ;
21
+ MainText = mainText ;
22
+ }
23
+ }
24
+
16
25
[ SerializeField ]
17
26
TextMeshProUGUI m_TitleText ;
18
27
[ SerializeField ]
19
28
TextMeshProUGUI m_MainText ;
20
29
30
+ Stack < PopupPanelData > m_PopupStack = new Stack < PopupPanelData > ( ) ;
31
+
21
32
static PopupPanel s_Instance ;
22
33
23
34
void Awake ( )
@@ -34,6 +45,10 @@ void OnDestroy()
34
45
public void OnConfirmClick ( )
35
46
{
36
47
ResetState ( ) ;
48
+ if ( m_PopupStack . Count > 0 )
49
+ {
50
+ SetupPopupPanel ( m_PopupStack . Pop ( ) ) ;
51
+ }
37
52
}
38
53
39
54
/// <summary>
@@ -52,24 +67,30 @@ void ResetState()
52
67
/// <param name="titleText">The title text at the top of the panel</param>
53
68
/// <param name="mainText"> The text just under the title- the main body of text</param>
54
69
/// <param name="confirmFunction"> The function to call when the confirm button is pressed.</param>
55
- public static void ShowPopupPanel ( string titleText , string mainText , Action confirmFunction = null )
70
+ public static void ShowPopupPanel ( string titleText , string mainText )
56
71
{
57
72
if ( s_Instance != null )
58
73
{
59
- s_Instance . SetupPopupPanel ( titleText , mainText , confirmFunction ) ;
74
+ s_Instance . StackPopupPanel ( new PopupPanelData ( titleText , mainText ) ) ;
60
75
}
61
76
else
62
77
{
63
78
Debug . LogError ( $ "No PopupPanel instance found. Cannot display message: { titleText } : { mainText } ") ;
64
79
}
65
80
}
66
81
67
- void SetupPopupPanel ( string titleText , string mainText , Action confirmFunction = null )
82
+ void StackPopupPanel ( PopupPanelData data )
83
+ {
84
+ m_PopupStack . Push ( data ) ;
85
+ SetupPopupPanel ( data ) ;
86
+ }
87
+
88
+ void SetupPopupPanel ( PopupPanelData data )
68
89
{
69
90
ResetState ( ) ;
70
91
71
- m_TitleText . text = titleText ;
72
- m_MainText . text = mainText ;
92
+ m_TitleText . text = data . TitleText ;
93
+ m_MainText . text = data . MainText ;
73
94
74
95
gameObject . SetActive ( true ) ;
75
96
}
0 commit comments