< Summary

Class:UIComponents.Scripts.Components.Text.TMPTextHyperLink
Assembly:UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Text/TMPTextHyperLink.cs
Covered lines:2
Uncovered lines:4
Coverable lines:6
Total lines:30
Line coverage:33.3% (2 of 6)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:2
Method coverage:50% (1 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%220100%
OnPointerClick(...)0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Text/TMPTextHyperLink.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.EventSystems;
 5
 6namespace UIComponents.Scripts.Components.Text
 7{
 8    public class TMPTextHyperLink : MonoBehaviour, IPointerClickHandler
 9    {
 10        [SerializeField] private TMP_Text tmpTextBox;
 11        [SerializeField] private Canvas canvasToCheck;
 12
 13        private Camera cameraToUse;
 14
 15        public event Action HyperLinkClicked;
 16
 17        private void Awake()
 18        {
 1319            cameraToUse = canvasToCheck.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvasToCheck.worldCamera;
 1320        }
 21
 22        public void OnPointerClick(PointerEventData eventData)
 23        {
 024            Vector3 mousePosition = new Vector3(eventData.position.x, eventData.position.y, 0); // or Input.mousePositio
 25
 026            if (TMP_TextUtilities.FindIntersectingLink(tmpTextBox, mousePosition, cameraToUse) != -1)
 027                HyperLinkClicked?.Invoke();
 028        }
 29    }
 30}