| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCL.LoadingScreen |
| | 6 | | { |
| | 7 | | public class LoadingScreenTimeoutView : MonoBehaviour, ILoadingScreenTimeoutView |
| | 8 | | { |
| | 9 | | [SerializeField] private GameObject websocketTimeout; |
| | 10 | | [SerializeField] private GameObject sceneTimeoutWebGL; |
| | 11 | | [SerializeField] private GameObject sceneTimeoutDesktop; |
| | 12 | | [SerializeField] private Button[] exitButtons; |
| | 13 | | [SerializeField] private Button[] goBackHomeButtons; |
| | 14 | |
|
| | 15 | | private GameObject currentSceneTimeoutContainer; |
| | 16 | | private bool goHomeRequested; |
| | 17 | |
|
| | 18 | | public event Action OnExitButtonClicked; |
| | 19 | | public event Action OnJumpHomeButtonClicked; |
| | 20 | |
|
| | 21 | | private void Awake() |
| | 22 | | { |
| 0 | 23 | | foreach (Button exitButton in exitButtons) |
| 0 | 24 | | exitButton.onClick.AddListener(() => OnExitButtonClicked?.Invoke()); |
| | 25 | |
|
| 0 | 26 | | foreach (Button goBackHomeButton in goBackHomeButtons) |
| 0 | 27 | | goBackHomeButton.onClick.AddListener(() => OnJumpHomeButtonClicked?.Invoke()); |
| | 28 | |
|
| | 29 | | //In desktop, first timeout corresponds to websocket. Thats why we have to define what is the first message |
| 0 | 30 | | currentSceneTimeoutContainer = Application.platform == RuntimePlatform.WebGLPlayer ? sceneTimeoutWebGL : web |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | public void ShowSceneTimeout() |
| | 34 | | { |
| 0 | 35 | | currentSceneTimeoutContainer.SetActive(true); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public void HideSceneTimeout() |
| | 39 | | { |
| 0 | 40 | | currentSceneTimeoutContainer.SetActive(false); |
| | 41 | |
|
| | 42 | | //Once the websocket has connected and the first fadeout has been done, its always a scene timeout |
| 0 | 43 | | currentSceneTimeoutContainer = Application.platform == RuntimePlatform.WebGLPlayer ? sceneTimeoutWebGL : sce |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | public void Dispose() |
| | 47 | | { |
| 0 | 48 | | foreach (Button exitButton in exitButtons) |
| 0 | 49 | | exitButton.onClick.RemoveAllListeners(); |
| | 50 | |
|
| 0 | 51 | | foreach (Button goBackHomeButton in goBackHomeButtons) |
| 0 | 52 | | goBackHomeButton.onClick.RemoveAllListeners(); |
| 0 | 53 | | } |
| | 54 | | } |
| | 55 | | } |