< Summary

Class:FirstPersonModeView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/FirstPersonMode/FirstPersonModeView.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:56
Line coverage:100% (15 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FirstPersonModeView()0%110100%
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
OnPointerClick()0%220100%
OnPointerEnter(...)0%220100%
OnPointerExit()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/FirstPersonMode/FirstPersonModeView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4using UnityEngine.UI;
 5
 6public interface IFirstPersonModeView
 7{
 8    event Action OnFirstPersonModeClick;
 9    event Action OnHideTooltip;
 10    event Action<BaseEventData, string> OnShowTooltip;
 11
 12    void OnPointerClick();
 13    void OnPointerEnter(PointerEventData eventData);
 14    void OnPointerExit();
 15}
 16
 17public class FirstPersonModeView : MonoBehaviour, IFirstPersonModeView
 18{
 19    public event Action OnFirstPersonModeClick;
 20    public event Action<BaseEventData, string> OnShowTooltip;
 21    public event Action OnHideTooltip;
 22
 23    [SerializeField] internal Button mainButton;
 2424    [SerializeField] internal string tooltipText = "Change Camera (I)";
 25    [SerializeField] internal EventTrigger changeModeEventTrigger;
 26
 27    private const string VIEW_PATH = "FirstPersonMode/FirstPersonModeView";
 28
 29    internal static FirstPersonModeView Create()
 30    {
 331        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<FirstPersonModeView>();
 332        view.gameObject.name = "_FirstPersonModeView";
 33
 334        return view;
 35    }
 36
 37    private void Awake()
 38    {
 439        mainButton.onClick.AddListener(OnPointerClick);
 440        BIWUtils.ConfigureEventTrigger(changeModeEventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPointerEn
 441        BIWUtils.ConfigureEventTrigger(changeModeEventTrigger, EventTriggerType.PointerExit, (eventData) => OnPointerExi
 442    }
 43
 44    private void OnDestroy()
 45    {
 446        mainButton.onClick.RemoveListener(OnPointerClick);
 447        BIWUtils.RemoveEventTrigger(changeModeEventTrigger, EventTriggerType.PointerEnter);
 448        BIWUtils.RemoveEventTrigger(changeModeEventTrigger, EventTriggerType.PointerExit);
 449    }
 50
 251    public void OnPointerClick() { OnFirstPersonModeClick?.Invoke(); }
 52
 253    public void OnPointerEnter(PointerEventData eventData) { OnShowTooltip?.Invoke(eventData, tooltipText); }
 54
 255    public void OnPointerExit() { OnHideTooltip?.Invoke(); }
 56}