< 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.075085.71%
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        {
 5717            Utils.OnCursorLockChanged += HandleCursorLockChanges;
 5718        }
 19
 20        private void OnDestroy()
 21        {
 5722            Utils.OnCursorLockChanged -= HandleCursorLockChanges;
 5723        }
 24
 25        private void HandleCursorLockChanges(bool isLocked)
 26        {
 1027            if (!isLocked)
 28            {
 529                toastRoot.Hide();
 530                return;
 31            }
 532            if (DataStore.i.camera.panning.Get()) return;
 633            if (hasBeenShown) return;
 434            if (toastRoot.isVisible) return;
 435            toastRoot.gameObject.SetActive(true);
 436            toastRoot.Show();
 437            hasBeenShown = true;
 438            HideToastAfterDelay();
 439        }
 40
 41        private void HideToastAfterDelay()
 42        {
 443            if (hideRoutine != null)
 044                StopCoroutine(hideRoutine);
 445            hideRoutine = StartCoroutine(Utils.Wait(duration, () =>
 46            {
 047                toastRoot.Hide();
 048                hideRoutine = null;
 049            }));
 450        }
 51    }
 52}