< Summary

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

Metrics

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

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/PublishBtnView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4using UnityEngine.UI;
 5
 6public interface IPublishBtnView
 7{
 8    event Action OnHideTooltip;
 9    event Action OnPublishButtonClick;
 10    event Action<BaseEventData, string> OnShowTooltip;
 11
 12    void OnPointerClick();
 13    void OnPointerEnter(PointerEventData eventData);
 14    void OnPointerExit();
 15    void SetInteractable(bool isInteractable);
 16}
 17
 18public class PublishBtnView : MonoBehaviour, IPublishBtnView
 19{
 20    public event Action OnPublishButtonClick;
 21    public event Action<BaseEventData, string> OnShowTooltip;
 22    public event Action OnHideTooltip;
 23
 24    [SerializeField] internal Button mainButton;
 2625    [SerializeField] internal string tooltipText = "Publish Scene";
 26    [SerializeField] internal EventTrigger publishButtonEventTrigger;
 27
 28    private const string VIEW_PATH = "GodMode/PublishBtnView";
 29
 30    internal static PublishBtnView Create()
 31    {
 532        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<PublishBtnView>();
 533        view.gameObject.name = "_PublishBtnView";
 34
 535        return view;
 36    }
 37
 38    private void Awake()
 39    {
 2440        mainButton.onClick.AddListener(OnPointerClick);
 2441        BIWUtils.ConfigureEventTrigger(publishButtonEventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPointe
 2442        BIWUtils.ConfigureEventTrigger(publishButtonEventTrigger, EventTriggerType.PointerExit, (eventData) => OnPointer
 2443    }
 44
 45    private void OnDestroy()
 46    {
 2447        mainButton.onClick.RemoveListener(OnPointerClick);
 2448        BIWUtils.RemoveEventTrigger(publishButtonEventTrigger, EventTriggerType.PointerEnter);
 2449        BIWUtils.RemoveEventTrigger(publishButtonEventTrigger, EventTriggerType.PointerExit);
 2450    }
 51
 252    public void OnPointerClick() { OnPublishButtonClick?.Invoke(); }
 53
 254    public void OnPointerEnter(PointerEventData eventData) { OnShowTooltip?.Invoke(eventData, tooltipText); }
 55
 256    public void OnPointerExit() { OnHideTooltip?.Invoke(); }
 57
 458    public void SetInteractable(bool isInteractable) { mainButton.interactable = isInteractable; }
 59}