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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%6200%
OnDestroy()0%2100%
RefreshChatLastCheckedTimestamp()0%2100%
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{
 326    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    {
 018        if (i != null)
 19        {
 020            Destroy(this);
 021            return;
 22        }
 23
 024        i = this;
 25
 026        RefreshChatLastCheckedTimestamp();
 027        CommonScriptableObjects.rendererState.OnChange += OnRendererStateChange;
 028        CommonScriptableObjects.allUIHidden.OnChange += OnAllUIHiddenChange;
 029    }
 30
 31    private void OnDestroy()
 32    {
 033        CommonScriptableObjects.rendererState.OnChange -= OnRendererStateChange;
 034        CommonScriptableObjects.allUIHidden.OnChange -= OnAllUIHiddenChange;
 035    }
 36
 37    public void RefreshChatLastCheckedTimestamp()
 38    {
 39        // Get UTC datetime (used to determine whether chat messages are old or new)
 040        chatLastCheckedTimestamp = (ulong)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalMillis
 041    }
 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}