< 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:15
Uncovered lines:7
Coverable lines:22
Total lines:58
Line coverage:68.1% (15 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%6200%
OnAllUIHiddenChange(...)0%220100%

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    {
 5118        if (i != null)
 19        {
 020            Destroy(this);
 021            return;
 22        }
 23
 5124        i = this;
 25
 5126        RefreshChatLastCheckedTimestamp();
 5127        CommonScriptableObjects.rendererState.OnChange += OnRendererStateChange;
 5128        CommonScriptableObjects.allUIHidden.OnChange += OnAllUIHiddenChange;
 5129    }
 30
 31    private void OnDestroy()
 32    {
 5133        CommonScriptableObjects.rendererState.OnChange -= OnRendererStateChange;
 5134        CommonScriptableObjects.allUIHidden.OnChange -= OnAllUIHiddenChange;
 5135    }
 36
 37    public void RefreshChatLastCheckedTimestamp()
 38    {
 39        // Get UTC datetime (used to determine whether chat messages are old or new)
 5140        chatLastCheckedTimestamp = (ulong)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalMillis
 5141    }
 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    {
 253        if (current)
 154            AudioScriptableObjects.UIHide.Play(true);
 55        else
 156            AudioScriptableObjects.UIShow.Play(true);
 157    }
 58}