< Summary

Class:ToggleAudioHandler
Assembly:HUDCommon
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Common/Audio/HUDElements/ToggleAudioHandler.cs
Covered lines:10
Uncovered lines:4
Coverable lines:14
Total lines:43
Line coverage:71.4% (10 of 14)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnPointerDown(...)0%12300%
OnValueChanged(...)0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Common/Audio/HUDElements/ToggleAudioHandler.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.EventSystems;
 3using UnityEngine.UI;
 4
 5public class ToggleAudioHandler : MonoBehaviour, IPointerDownHandler
 6{
 7    Toggle toggle;
 8
 9    void Awake()
 10    {
 8511        toggle = GetComponent<Toggle>();
 8512        toggle.onValueChanged.AddListener(OnValueChanged);
 8513    }
 14
 15    public void OnPointerDown(PointerEventData eventData)
 16    {
 017        if (toggle != null)
 18        {
 019            if (toggle.interactable)
 20            {
 021                AudioScriptableObjects.buttonClick.Play(true);
 22            }
 23        }
 024    }
 25
 26    public void OnValueChanged(bool isOn)
 27    {
 1228        if (toggle != null)
 29        {
 1230            if (toggle.interactable)
 31            {
 1232                if (isOn)
 33                {
 334                    AudioScriptableObjects.enable.Play(true);
 335                }
 36                else
 37                {
 938                    AudioScriptableObjects.disable.Play(true);
 39                }
 40            }
 41        }
 942    }
 43}