-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanel.cs
63 lines (57 loc) · 1.51 KB
/
Panel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Panel : MonoBehaviour
{
//0: Home, 1: Settings, 2: YesNoPopup
[SerializeField] protected PanelElement[] panelElements;
public UISound uISound;
public GameObject gameplayCanvas;
private void Awake()
{
InitializePanelElements();
}
public void Enable()
{
if (!gameObject.activeSelf)
{
gameObject.SetActive(true);
}
}
protected void Disable()
{
gameObject.SetActive(false);
}
public void Close()
{
if (gameObject.activeSelf)
{
LeanTween.moveLocalX(gameObject, -2000f, .25f).setEaseOutCubic().setOnComplete(Disable);
CloseAllActivePanelElements();
}
}
private void OnDisable()
{
gameplayCanvas.SetActive(true);
}
private void OnEnable()
{
gameplayCanvas.SetActive(false);
LeanTween.moveLocalX(gameObject, 0f, .25f).setEaseInCubic().setOnComplete(panelElements[0].Enable);
}
public void CloseAllActivePanelElements()
{
for (int i = 0; i < panelElements.Length; i++)
{
panelElements[i].Close();
}
uISound.PlayAudio(uISound.closePage);
}
protected void InitializePanelElements()
{
for (int i = 0; i < panelElements.Length; i++)
{
panelElements[i].Initialize();
}
}
}