| | 1 | | using DCL.Helpers; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL |
| | 5 | | { |
| | 6 | | public class CursorLockHint : MonoBehaviour |
| | 7 | | { |
| | 8 | | private bool hasBeenShown; |
| | 9 | |
|
| | 10 | | [SerializeField] private ShowHideAnimator toastRoot; |
| | 11 | | [SerializeField] private float duration; |
| | 12 | |
|
| | 13 | | private void Start() |
| | 14 | | { |
| 3 | 15 | | Utils.OnCursorLockChanged += HandleCursorLockChanges; |
| 3 | 16 | | } |
| | 17 | |
|
| | 18 | | private void OnDestroy() |
| | 19 | | { |
| 3 | 20 | | Utils.OnCursorLockChanged -= HandleCursorLockChanges; |
| 3 | 21 | | } |
| | 22 | |
|
| | 23 | | private void HandleCursorLockChanges(bool isLocked) |
| | 24 | | { |
| 0 | 25 | | if (!isLocked) |
| | 26 | | { |
| 0 | 27 | | toastRoot.Hide(); |
| 0 | 28 | | return; |
| | 29 | | } |
| | 30 | |
|
| 0 | 31 | | if (DataStore.i.camera.panning.Get() || hasBeenShown || toastRoot.isVisible) |
| 0 | 32 | | return; |
| | 33 | |
|
| 0 | 34 | | hasBeenShown = true; |
| 0 | 35 | | toastRoot.ShowDelayHide(duration); |
| 0 | 36 | | } |
| | 37 | | } |
| | 38 | | } |