< Summary

Class:CursorController
Assembly:DCL.Runtime
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CursorController.cs
Covered lines:21
Uncovered lines:1
Coverable lines:22
Total lines:57
Line coverage:95.4% (21 of 22)
Covered branches:0
Total branches:0
Covered methods:6
Total methods:6
Method coverage:100% (6 of 6)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnDestroy()0%110100%
OnChangeType(...)0%330100%
SetCursor(...)0%110100%
AllUIVisible_OnChange(...)0%110100%
ChangeCursorVisible(...)0%3.143075%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CursorController.cs

#LineLine coverage
 1using DCL;
 2using UnityEngine;
 3using UnityEngine.UI;
 4using static DCL.DataStore_Cursor;
 5
 6public class CursorController : MonoBehaviour
 7{
 8    public Image cursorImage;
 9    public Sprite normalCursor;
 10    public Sprite hoverCursor;
 11
 12    private Coroutine alphaRoutine;
 13    private bool isAllUIHidden;
 14
 15    [SerializeField] private ShowHideAnimator animator;
 16
 17    private void Awake()
 18    {
 32919        DataStore_Cursor data = DataStore.i.Get<DataStore_Cursor>();
 32920        data.cursorVisible.OnChange += ChangeCursorVisible;
 32921        data.cursorType.OnChange += OnChangeType;
 32922        CommonScriptableObjects.allUIHidden.OnChange += AllUIVisible_OnChange;
 32923    }
 24
 25    private void OnDestroy()
 26    {
 32927        DataStore_Cursor data = DataStore.i.Get<DataStore_Cursor>();
 32928        data.cursorVisible.OnChange -= ChangeCursorVisible;
 32929        data.cursorType.OnChange -= OnChangeType;
 32930        CommonScriptableObjects.allUIHidden.OnChange -= AllUIVisible_OnChange;
 32931    }
 32
 33    private void OnChangeType(CursorType current, CursorType _) =>
 834        SetCursor(current == CursorType.HOVER ? hoverCursor : normalCursor);
 35
 36    public void SetCursor(Sprite sprite)
 37    {
 1338        cursorImage.sprite = sprite;
 1339        cursorImage.SetNativeSize();
 1340    }
 41
 42    private void AllUIVisible_OnChange(bool current, bool previous)
 43    {
 1044        isAllUIHidden = current;
 45
 1046        DataStore_Cursor data = DataStore.i.Get<DataStore_Cursor>();
 1047        ChangeCursorVisible(data.cursorVisible.Get());
 1048    }
 49
 50    private void ChangeCursorVisible(bool current, bool _ = false)
 51    {
 4852        if (current && !isAllUIHidden)
 053            animator.Show();
 54        else
 4855            animator.Hide();
 4856    }
 57}