< Summary

Class:InspectorBtnView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/InspectorBtnView.cs
Covered lines:17
Uncovered lines:0
Coverable lines:17
Total lines:61
Line coverage:100% (17 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
InspectorBtnView()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/GodMode/Inspector/InspectorBtnView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4using UnityEngine.UI;
 5
 6public interface IInspectorBtnView
 7{
 8    event Action OnHideTooltip;
 9    event Action OnInspectorButtonClick;
 10    event Action<BaseEventData, string> OnShowTooltip;
 11
 12    void OnPointerClick(DCLAction_Trigger action);
 13    void OnPointerEnter(PointerEventData eventData);
 14    void OnPointerExit();
 15}
 16
 17public class InspectorBtnView : MonoBehaviour, IInspectorBtnView
 18{
 19    public event Action OnInspectorButtonClick;
 20    public event Action<BaseEventData, string> OnShowTooltip;
 21    public event Action OnHideTooltip;
 22
 23    [SerializeField] internal Button mainButton;
 2424    [SerializeField] internal string tooltipText = "Open Entity List (Q)";
 25    [SerializeField] internal EventTrigger inspectorButtonEventTrigger;
 26    [SerializeField] internal InputAction_Trigger toggleOpenEntityListInputAction;
 27
 28    private DCLAction_Trigger dummyActionTrigger = new DCLAction_Trigger();
 29
 30    private const string VIEW_PATH = "GodMode/Inspector/InspectorBtnView";
 31
 32    internal static InspectorBtnView Create()
 33    {
 334        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<InspectorBtnView>();
 335        view.gameObject.name = "_InspectorBtnView";
 36
 337        return view;
 38    }
 39
 40    private void Awake()
 41    {
 2242        mainButton.onClick.AddListener(() => OnPointerClick(dummyActionTrigger));
 2243        toggleOpenEntityListInputAction.OnTriggered += OnPointerClick;
 2244        BIWUtils.ConfigureEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPoin
 2245        BIWUtils.ConfigureEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerExit, (eventData) => OnPoint
 2246    }
 47
 48    private void OnDestroy()
 49    {
 2250        mainButton.onClick.RemoveAllListeners();
 2251        toggleOpenEntityListInputAction.OnTriggered -= OnPointerClick;
 2252        BIWUtils.RemoveEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerEnter);
 2253        BIWUtils.RemoveEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerExit);
 2254    }
 55
 256    public void OnPointerClick(DCLAction_Trigger action) { OnInspectorButtonClick?.Invoke(); }
 57
 258    public void OnPointerEnter(PointerEventData eventData) { OnShowTooltip?.Invoke(eventData, tooltipText); }
 59
 260    public void OnPointerExit() { OnHideTooltip?.Invoke(); }
 61}