< Summary

Class:HUDAudioHandler
Assembly:HUDCommon
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Common/Audio/HUDAudioHandler.cs
Covered lines:14
Uncovered lines:8
Coverable lines:22
Total lines:58
Line coverage:63.6% (14 of 22)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:7
Method coverage:71.4% (5 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%220100%
OnDestroy()0%110100%
RefreshChatLastCheckedTimestamp()0%110100%
OnRendererStateChange(...)0%6200%
OnAllUIHiddenChange(...)0%6200%

File(s)

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

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.Audio;
 3
 4public class HUDAudioHandler : MonoBehaviour
 5{
 446    public static HUDAudioHandler i { get; private set; }
 7
 8    [SerializeField]
 9    AudioMixer audioMixer;
 10    [SerializeField]
 11    AudioMixerSnapshot snapshotInWorld, snapshotOutOfWorld;
 12
 13    [HideInInspector]
 14    public ulong chatLastCheckedTimestamp;
 15
 16    private void Awake()
 17    {
 2518        if (i != null)
 19        {
 1820            Destroy(this);
 1821            return;
 22        }
 23
 724        i = this;
 25
 726        RefreshChatLastCheckedTimestamp();
 727        CommonScriptableObjects.rendererState.OnChange += OnRendererStateChange;
 728        CommonScriptableObjects.allUIHidden.OnChange += OnAllUIHiddenChange;
 729    }
 30
 31    private void OnDestroy()
 32    {
 2533        CommonScriptableObjects.rendererState.OnChange -= OnRendererStateChange;
 2534        CommonScriptableObjects.allUIHidden.OnChange -= OnAllUIHiddenChange;
 2535    }
 36
 37    public void RefreshChatLastCheckedTimestamp()
 38    {
 39        // Get UTC datetime (used to determine whether chat messages are old or new)
 740        chatLastCheckedTimestamp = (ulong)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalMillis
 741    }
 42
 43    void OnRendererStateChange(bool isReady, bool isReadyPrevious)
 44    {
 045        if (isReady)
 046            snapshotInWorld.TransitionTo(0.1f);
 47        else
 048            snapshotOutOfWorld.TransitionTo(0.2f);
 049    }
 50
 51    void OnAllUIHiddenChange(bool current, bool previous)
 52    {
 053        if (current)
 054            AudioScriptableObjects.UIHide.Play(true);
 55        else
 056            AudioScriptableObjects.UIShow.Play(true);
 057    }
 58}