| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public interface IShortcutsView |
| | 6 | | { |
| | 7 | | event Action OnCloseButtonClick; |
| | 8 | |
|
| | 9 | | void OnCloseClick(); |
| | 10 | | void SetActive(bool isActive); |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public class ShortcutsView : MonoBehaviour, IShortcutsView |
| | 14 | | { |
| | 15 | | public event Action OnCloseButtonClick; |
| | 16 | |
|
| | 17 | | [SerializeField] internal Button closeButton; |
| | 18 | |
|
| | 19 | | private const string VIEW_PATH = "Common/ShortcutsView"; |
| | 20 | |
|
| | 21 | | internal static ShortcutsView Create() |
| | 22 | | { |
| 3 | 23 | | var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<ShortcutsView>(); |
| 3 | 24 | | view.gameObject.name = "_ShortcutsView"; |
| | 25 | |
|
| 3 | 26 | | return view; |
| | 27 | | } |
| | 28 | |
|
| 6 | 29 | | private void Awake() { closeButton.onClick.AddListener(OnCloseClick); } |
| | 30 | |
|
| 8 | 31 | | private void OnEnable() { AudioScriptableObjects.dialogOpen.Play(); } |
| | 32 | |
|
| 8 | 33 | | private void OnDisable() { AudioScriptableObjects.dialogClose.Play(); } |
| | 34 | |
|
| 4 | 35 | | public void SetActive(bool isActive) { gameObject.SetActive(isActive); } |
| | 36 | |
|
| 2 | 37 | | public void OnCloseClick() { OnCloseButtonClick?.Invoke(); } |
| | 38 | | } |