< Summary

Class:EmotesHUDView
Assembly:EmotesHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/EmotesHUD/EmotesHUDView.cs
Covered lines:16
Uncovered lines:5
Coverable lines:21
Total lines:69
Line coverage:76.1% (16 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%220100%
Initialize(...)0%220100%
UpdateAvatarSprite(...)0%6200%
SetVisiblity(...)0%220100%
Close()0%6200%
OnDestroy()0%110100%
CleanUp()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/EmotesHUD/EmotesHUDView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.Serialization;
 4using UnityEngine.UI;
 5
 6public class EmotesHUDView : MonoBehaviour
 7{
 8    private const string PATH = "EmotesHUD";
 9
 10    public delegate void ExpressionClicked(string expressionId);
 11    public event Action OnClose;
 12
 13    [Serializable]
 14    public class ButtonToEmote
 15    {
 16        public string expressionId;
 17        public Button_OnPointerDown button; // When the button is used to lock/unlock the mouse we have to use onPointer
 18    }
 19
 20    [SerializeField] internal ButtonToEmote[] buttonToEmotesMap;
 21    [SerializeField] internal Button_OnPointerDown[] closeButtons;
 22    [SerializeField] internal RawImage avatarPic;
 23
 624    public static EmotesHUDView Create() { return Instantiate(Resources.Load<GameObject>(PATH)).GetComponent<EmotesHUDVi
 25
 26    private void Awake()
 27    {
 3628        for (int i = 0; i < closeButtons.Length; i++)
 29        {
 1230            closeButtons[i].onPointerDown += Close;
 31        }
 632    }
 33
 34    internal void Initialize(ExpressionClicked clickedDelegate)
 35    {
 11236        foreach (var buttonToExpression in buttonToEmotesMap)
 37        {
 5138            buttonToExpression.button.onPointerDown += () => clickedDelegate?.Invoke(buttonToExpression.expressionId);
 39        }
 740    }
 41
 42    public void UpdateAvatarSprite(Texture2D avatarTexture)
 43    {
 044        if (avatarTexture == null)
 045            return;
 46
 047        avatarPic.texture = avatarTexture;
 048    }
 49
 50    public void SetVisiblity(bool visible)
 51    {
 852        gameObject.SetActive(visible);
 853        if (visible)
 154            AudioScriptableObjects.dialogOpen.Play(true);
 55        else
 756            AudioScriptableObjects.dialogClose.Play(true);
 757    }
 58
 059    private void Close() { OnClose?.Invoke(); }
 1260    public void OnDestroy() { CleanUp(); }
 61
 62    public void CleanUp()
 63    {
 7264        for (int i = 0; i < closeButtons.Length; i++)
 65        {
 2466            closeButtons[i].onPointerDown -= Close;
 67        }
 1268    }
 69}