< Summary

Class:DCL.CursorLockHint
Assembly:MouseCatcher
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/MouseCatcher/CursorLockHint.cs
Covered lines:18
Uncovered lines:4
Coverable lines:22
Total lines:52
Line coverage:81.8% (18 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%110100%
OnDestroy()0%110100%
HandleCursorLockChanges(...)0%5.255078.57%
HideToastAfterDelay()0%2.062075%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/MouseCatcher/CursorLockHint.cs

#LineLine coverage
 1using DCL.Helpers;
 2using UnityEngine;
 3
 4namespace 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 Coroutine hideRoutine;
 14
 15        private void Start()
 16        {
 3517            Utils.OnCursorLockChanged += HandleCursorLockChanges;
 3518        }
 19
 20        private void OnDestroy()
 21        {
 3522            Utils.OnCursorLockChanged -= HandleCursorLockChanges;
 3523        }
 24
 25        private void HandleCursorLockChanges(bool isLocked)
 26        {
 227            if (!isLocked)
 28            {
 129                toastRoot.Hide();
 130                return;
 31            }
 132            if (DataStore.i.camera.panning.Get()) return;
 133            if (hasBeenShown) return;
 134            if (toastRoot.isVisible) return;
 135            toastRoot.gameObject.SetActive(true);
 136            toastRoot.Show();
 137            hasBeenShown = true;
 138            HideToastAfterDelay();
 139        }
 40
 41        private void HideToastAfterDelay()
 42        {
 143            if (hideRoutine != null)
 044                StopCoroutine(hideRoutine);
 145            hideRoutine = StartCoroutine(Utils.Wait(duration, () =>
 46            {
 047                toastRoot.Hide();
 048                hideRoutine = null;
 049            }));
 150        }
 51    }
 52}