| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public class NavmapCloseButtonBehaviour: IDisposable |
| | 8 | | { |
| | 9 | | private readonly Button closeButton; |
| | 10 | |
|
| | 11 | | private readonly BaseVariable<bool> navmapVisible; |
| | 12 | | private readonly BaseVariable<Transform> configureMapInFullscreenMenu; |
| | 13 | |
|
| 54 | 14 | | public NavmapCloseButtonBehaviour (Button closeButton, BaseVariable<bool> navmapVisible, BaseVariable<Transform> |
| | 15 | | { |
| 54 | 16 | | this.navmapVisible = navmapVisible; |
| | 17 | |
|
| 54 | 18 | | this.closeButton = closeButton; |
| 54 | 19 | | this.configureMapInFullscreenMenu = configureMapInFullscreenMenu; |
| | 20 | |
|
| 54 | 21 | | closeButton.onClick.AddListener(OnCloseButtonClicked); |
| 54 | 22 | | configureMapInFullscreenMenu.OnChange += HideCloseButton; |
| 54 | 23 | | } |
| | 24 | |
|
| | 25 | | public void Dispose() |
| | 26 | | { |
| 54 | 27 | | closeButton.onClick.RemoveListener(OnCloseButtonClicked); |
| 54 | 28 | | configureMapInFullscreenMenu.OnChange -= HideCloseButton; |
| 54 | 29 | | } |
| | 30 | |
|
| 0 | 31 | | private void OnCloseButtonClicked() => navmapVisible.Set(false); |
| | 32 | |
|
| | 33 | | private void HideCloseButton(Transform currentParentTransform, Transform _) |
| | 34 | | { |
| 0 | 35 | | if (currentParentTransform != null) |
| 0 | 36 | | closeButton.gameObject.SetActive(false); |
| 0 | 37 | | } |
| | 38 | | } |
| | 39 | | } |