Clickable Links in Unity Text: Hover, Click and URLs
Last reviewed
Short answer
TextMesh Pro marks links with a <link> tag but leaves the rest to your code: finding which link the pointer is over, hover and pressed styling, and opening the URL.
UniText ships links as a ready style: <link=url> tags, Markdown [text](url) and bare URLs become clickable with hover and pressed states, open in the browser by default and raise click and hover events, on canvas and world-space text alike.
The usual options
- TextMesh Pro. The
<link>tag stores an ID and does not change how the text looks.TMP_TextUtilities.FindIntersectingLinkreturns which link is under a point; click handling, hover and pressed colors and opening the URL are your code. The bundled example scripts handle hover only and read the legacyInputclass, which throws when a project uses only the Input System. - UI Toolkit. An
<a href>link opens its URL on click. A<link>tag raises pointer events that are still marked experimental, and hover styling is done by hand with inline color tags and USS classes. - Helper libraries. Open-source helpers such as FancyTextRendering add normal, hover and click colors and click actions on top of TextMesh Pro's link tags.
How UniText handles links
- Three ways to write a link.
LinkModifierwith its parse rules recognizes explicit<link=url>tags, Markdown[text](url)and bare addresses such ashttps://,www.,mailto:andtel:. - Behavior included. With
AutoOpenUrlon, a click opens the URL throughApplication.OpenURL.LinkClicked,LinkEnteredandLinkExitedfire for your own handling. - States and styling. Each link range moves through Normal, Hovered, Pressed and Disabled, and the built-in link preset combines color, underline and highlight with rules for each state.
- Any interactive range. The same machinery drives spoilers, @mentions and #tags detected automatically, and your own clickable ranges carrying an ID or an object payload, with keyboard navigation and long-press.
- Scroll views and world space. Viewport adapters keep hit-testing correct inside a
ScrollRectand for world-space text seen by a camera.
csharp
using LightSide;
using UnityEngine;
public sealed class ProfileLinks : MonoBehaviour
{
[SerializeField] UniTextBase text;
[SerializeField] RangeChannel channel;
RangeInteractionEvents events;
void OnEnable()
{
events = UniTextInteractions.For(text).Get(channel);
events.Activated += OnActivated;
}
void OnDisable() => events.Activated -= OnActivated;
void OnActivated(RangeInteraction interaction)
=> Debug.Log($"Open profile {interaction.Range.PrimaryValue}", text);
}Questions
Can a link open something inside the game instead of a browser?
Yes. Turn off
AutoOpenUrl or use a plain interactive range, and handle the click in code with the range's value, such as a user ID or an item key.Do links work inside right-to-left text?
Yes. Hit-testing follows the laid-out glyphs, so a link inside Arabic or Hebrew text is clicked where it is drawn.
Can players select and copy linked text?
Yes, with the selectable or editable components. Copying keeps links as Markdown or HTML when the destination accepts formatting.
Check it in your project
Run the browser demo, follow the setup guide, or compare the free version with the licenses.
Related problems
- Icons, Images and Buttons Inside Unity TextTextMesh Pro draws inline icons from packed sprite assets and cannot place objects in the text. UniText lays out sprites, prefabs and scene objects as characters that wrap and align with the line.
- Unity Input Field With IME, Arabic, Emoji and Mobile KeyboardsUnity input fields struggle with IME, right-to-left typing, emoji and WebGL. UniText edits shaped text with native OS input, first-class IME composition and cluster-aware caret movement, whatever the input setting.
- Markdown in Unity Text: Bold, Links and Lists Without ConversionTextMesh Pro and UI Toolkit show Markdown as raw asterisks. UniText reads inline Markdown directly, including bold, italic, links, lists and code spans, and copies formatted text as Markdown or HTML.
