< Summary

Class:UIUtil_ChangeTextAndIconColorOnFocus
Assembly:UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Utils/UIUtil_ChangeTextAndIconColorOnFocus.cs
Covered lines:10
Uncovered lines:0
Coverable lines:10
Total lines:36
Line coverage:100% (10 of 10)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Start()0%110100%
OnDestroy()0%110100%
ComponentView_onFocused(...)0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Utils/UIUtil_ChangeTextAndIconColorOnFocus.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5[RequireComponent(typeof(BaseComponentView))]
 6public class UIUtil_ChangeTextAndIconColorOnFocus : MonoBehaviour
 7{
 8    [SerializeField] internal TMP_Text textToChange;
 9    [SerializeField] internal Image iconToChange;
 10    [SerializeField] internal Color onFocusColor;
 11    [SerializeField] internal Color onLoseFocusColor;
 12
 13    internal BaseComponentView componentView;
 14
 15    private void Awake()
 16    {
 99817        componentView = GetComponent<BaseComponentView>();
 99818    }
 19
 20    private void Start()
 21    {
 122        componentView.onFocused += ComponentView_onFocused;
 123        ComponentView_onFocused(componentView.isFocused);
 124    }
 25
 26    private void OnDestroy()
 27    {
 99828        componentView.onFocused -= ComponentView_onFocused;
 99829    }
 30
 31    private void ComponentView_onFocused(bool isFocused)
 32    {
 333        textToChange.color = isFocused ? onFocusColor : onLoseFocusColor;
 334        iconToChange.color = isFocused ? onFocusColor : onLoseFocusColor;
 335    }
 36}