Skip to content

Commit 660c39a

Browse files
committed
**New**:
- Added *InteractableTextView* script to allow linking text code execution, e.g open URLs in the broser **Changed**: - Renamed *AdjustScreenSizeFitter* to *AdjustScreenSizeFitterView* to mark it as a View in the architecture conventions - Moved *AdjustScreenSizeFitterView* and *NonDrawingView*, *SafeAreaHelperView* to the Views folder and namespace to organize the codebase accordingly
1 parent 4dcf006 commit 660c39a

13 files changed

+91
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [0.12.0] - 2025-01-08
8+
9+
**New**:
10+
- Added *InteractableTextView* script to allow linking text code execution, e.g open URLs in the broser
11+
12+
**Changed**:
13+
- Renamed *AdjustScreenSizeFitter* to *AdjustScreenSizeFitterView* to mark it as a View in the architecture conventions
14+
- Moved *AdjustScreenSizeFitterView* and *NonDrawingView*, *SafeAreaHelperView* to the Views folder and namespace to organize the codebase accordingly
15+
716
## [0.11.0] - 2025-01-05
817

918
**New**:

Editor/NonDrawingViewEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GameLovers.UiService;
1+
using GameLovers.UiService.Views;
22
using UnityEditor;
33
using UnityEditor.UI;
44
using UnityEngine;

Runtime/GameLovers.UiService.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"references": [
55
"GUID:84651a3751eca9349aac36a66bba901b",
66
"GUID:9e24947de15b9834991c9d8411ea37cf",
7+
"GUID:6055be8ebefd69e48b49212b09b47b2f",
78
"GUID:f51ebe6a0ceec4240a699833d6309b23"
89
],
910
"includePlatforms": [],

Runtime/Views.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/AdjustScreenSizeFitter.cs renamed to Runtime/Views/AdjustScreenSizeFitterView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using UnityEngine.EventSystems;
44
using UnityEngine.UI;
55

6-
namespace GameLovers.UiService
6+
namespace GameLovers.UiService.Views
77
{
88
/// <summary>
99
/// Resizes a RectTransform to fit the size of its content.
@@ -15,7 +15,7 @@ namespace GameLovers.UiService
1515
[AddComponentMenu("Layout/Adjust Size Fitter", 141)]
1616
[ExecuteAlways]
1717
[RequireComponent(typeof(RectTransform), typeof(LayoutElement))]
18-
public class AdjustScreenSizeFitter : UIBehaviour, ILayoutSelfController
18+
public class AdjustScreenSizeFitterView : UIBehaviour, ILayoutSelfController
1919
{
2020
[SerializeField] private RectOffset _padding = new RectOffset();
2121
[SerializeField] private RectTransform _canvasTransform;

Runtime/AdjustScreenSizeFitter.cs.meta renamed to Runtime/Views/AdjustScreenSizeFitterView.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using TMPro;
3+
using UnityEngine;
4+
using UnityEngine.Events;
5+
using UnityEngine.EventSystems;
6+
7+
namespace GameLovers.UiService.Views
8+
{
9+
/// <summary>
10+
/// This view is responsible to handle all types of links (ex: hyperlinks) set in the <see cref="TMP_Text"/>
11+
/// </summary>
12+
[RequireComponent(typeof(TMP_Text))]
13+
public class InteractableTextView : MonoBehaviour, IPointerClickHandler
14+
{
15+
public enum InteractableTextType
16+
{
17+
IntersectingLink,
18+
NearestLink
19+
}
20+
21+
public UnityEvent<TMP_LinkInfo> OnLinkedInfoClicked;
22+
public InteractableTextType InteractableType;
23+
24+
[SerializeField] private TMP_Text _text;
25+
26+
public TMP_Text Text => _text;
27+
28+
private void OnValidate()
29+
{
30+
_text = _text == null ? GetComponent<TMP_Text>() : _text;
31+
}
32+
33+
public void OnPointerClick(PointerEventData eventData)
34+
{
35+
// Get Canvas Camera if using WorldCamera view
36+
var linkedText = -1;
37+
38+
if (InteractableType == InteractableTextType.IntersectingLink)
39+
{
40+
linkedText = TMP_TextUtilities.FindIntersectingLink(_text, eventData.position, null);
41+
}
42+
else
43+
{
44+
linkedText = TMP_TextUtilities.FindNearestLink(_text, eventData.position, null);
45+
}
46+
47+
if (linkedText > -1)
48+
{
49+
OnLinkedInfoClicked.Invoke(_text.textInfo.linkInfo[linkedText]);
50+
}
51+
}
52+
}
53+
}

Runtime/Views/InteractableTextView.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/NonDrawingView.cs renamed to Runtime/Views/NonDrawingView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// ReSharper disable CheckNamespace
55

6-
namespace GameLovers.UiService
6+
namespace GameLovers.UiService.Views
77
{
88
/// <summary>
99
/// A concrete subclass of the Unity UI `Graphic` class that just skips drawing.
File renamed without changes.

0 commit comments

Comments
 (0)