< 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:16
Uncovered lines:6
Coverable lines:22
Total lines:58
Line coverage:72.7% (16 of 22)
Covered branches:0
Total branches:0

Metrics

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

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{
 06    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    {
 5218        if (i != null)
 19        {
 020            Destroy(this);
 021            return;
 22        }
 23
 5224        i = this;
 25
 5226        RefreshChatLastCheckedTimestamp();
 5227        CommonScriptableObjects.rendererState.OnChange += OnRendererStateChange;
 5228        CommonScriptableObjects.allUIHidden.OnChange += OnAllUIHiddenChange;
 5229    }
 30
 31    private void OnDestroy()
 32    {
 5233        CommonScriptableObjects.rendererState.OnChange -= OnRendererStateChange;
 5234        CommonScriptableObjects.allUIHidden.OnChange -= OnAllUIHiddenChange;
 5235    }
 36
 37    public void RefreshChatLastCheckedTimestamp()
 38    {
 39        // Get UTC datetime (used to determine whether chat messages are old or new)
 5240        chatLastCheckedTimestamp = (ulong)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalMillis
 5241    }
 42
 43    void OnRendererStateChange(bool isReady, bool isReadyPrevious)
 44    {
 5245        if (isReady)
 046            snapshotInWorld.TransitionTo(0.1f);
 47        else
 5248            snapshotOutOfWorld.TransitionTo(0.2f);
 5249    }
 50
 51    void OnAllUIHiddenChange(bool current, bool previous)
 52    {
 153        if (current)
 154            AudioScriptableObjects.UIHide.Play(true);
 55        else
 056            AudioScriptableObjects.UIShow.Play(true);
 057    }
 58}