Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)

## [0.12.0] - 2025-01-08

**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

## [0.11.0] - 2025-01-05

**New**:
Expand Down
2 changes: 1 addition & 1 deletion Editor/NonDrawingViewEditor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GameLovers.UiService;
using GameLovers.UiService.Views;
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
Expand Down
1 change: 1 addition & 0 deletions Runtime/GameLovers.UiService.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"references": [
"GUID:84651a3751eca9349aac36a66bba901b",
"GUID:9e24947de15b9834991c9d8411ea37cf",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
Expand Down
8 changes: 8 additions & 0 deletions Runtime/Views.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UnityEngine.EventSystems;
using UnityEngine.UI;

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions Runtime/Views/InteractableTextView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

namespace GameLovers.UiService.Views
{
/// <summary>
/// This view is responsible to handle all types of links (ex: hyperlinks) set in the <see cref="TMP_Text"/>
/// </summary>
[RequireComponent(typeof(TMP_Text))]
public class InteractableTextView : MonoBehaviour, IPointerClickHandler
{
public enum InteractableTextType
{
IntersectingLink,
NearestLink
}

public UnityEvent<TMP_LinkInfo> OnLinkedInfoClicked;
public InteractableTextType InteractableType;

[SerializeField] private TMP_Text _text;

public TMP_Text Text => _text;

private void OnValidate()
{
_text = _text == null ? GetComponent<TMP_Text>() : _text;
}

public void OnPointerClick(PointerEventData eventData)
{
// Get Canvas Camera if using WorldCamera view
var linkedText = -1;

if (InteractableType == InteractableTextType.IntersectingLink)
{
linkedText = TMP_TextUtilities.FindIntersectingLink(_text, eventData.position, null);
}
else
{
linkedText = TMP_TextUtilities.FindNearestLink(_text, eventData.position, null);
}

if (linkedText > -1)
{
OnLinkedInfoClicked.Invoke(_text.textInfo.linkInfo[linkedText]);
}
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Views/InteractableTextView.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// ReSharper disable CheckNamespace

namespace GameLovers.UiService
namespace GameLovers.UiService.Views
{
/// <summary>
/// A concrete subclass of the Unity UI `Graphic` class that just skips drawing.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// ReSharper disable CheckNamespace

namespace GameLovers.UiService
namespace GameLovers.UiService.Views
{
/// <summary>
/// This view helper translate anchored views based on device safe area (screens witch a notch)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "com.gamelovers.uiservice",
"displayName": "UiService",
"author": "Miguel Tomas",
"version": "0.11.0",
"version": "0.12.0",
"unity": "2022.3",
"license": "MIT",
"description": "This package provides a service to help manage an Unity's, game UI.\nIt allows to open, close, load, unload and request any Ui Configured in the game.\nThe package provides a Ui Set that allows to group a set of Ui Presenters to help load, open and close multiple Uis at the same time.\n\nTo help configure the game's UI you need to create a UiConfigs Scriptable object by:\n- Right Click on the Project View > Create > ScriptableObjects > Configs > UiConfigs",
"dependencies": {
"com.unity.addressables": "1.22.0",
"com.cysharp.unitask": "2.5.10"
"com.cysharp.unitask": "2.5.10",
"com.unity.textmeshpro": "3.0.9"
},
"type": "library",
"hideInEditor": false
Expand Down