Version 1.0.0. A short overview is in the README.md file and the release history is in the CHANGELOG.md file, both in the root folder of the package.
Overview
Markdown Viewer shows Markdown inside your game or app. Assign a .md file to a component and you get a scrolling, styled document with headings, lists, task lists, tables, block quotes, code blocks, images, rules and clickable links.
- uGUI. The
MarkdownViewcomponent builds the document as child GameObjects of a Canvas, with Unity'sTextcomponent (the default, no setup) or with TextMeshPro. - UI Toolkit. The
MarkdownElementvisual element builds the same document as child elements, from UXML or from code. - What's New. The
WhatsNewPopupcomponent reads your changelog and shows the player only the versions released since the one they last saw.MarkdownChangeloggives you the same data for your own UI.
Both renderers are fed by one parser that is part of the package and one document tree, so a document looks and behaves the same way in both. The parser follows CommonMark with the GitHub tables, strikethrough, task lists and bare web addresses; raw HTML is not interpreted (see Differences from CommonMark and GitHub).
What you do not have to do: install a Markdown library, add an importer (Unity already imports .md files as TextAsset), write shaders, or set anything up per platform. The package is C# only: no native code, no shaders, no materials, and nothing is loaded from a network.
Requirements
- Unity 6000.0.84f1 or newer. Tested with 6000.0.84f1 and 6000.3.12f1 only; see Tested on.
- The built-in modules UI and UIElements. The package declares them, so Unity enables them with the package.
- uGUI (
com.unity.ugui) forMarkdownViewandWhatsNewPopup. Every new Unity project has it. Without it these two types do not exist, and the rest of the package (the parser,MarkdownElement,MarkdownChangelog, themes) still compiles and works. - TextMeshPro mode needs the TMP Essential Resources in the project (Window > TextMeshPro > Import TMP Essential Resources). TextMeshPro is part of
com.unity.uguiin Unity 6. - UI Toolkit views need nothing else.
- The Input System package is optional. The views use whatever the EventSystem or the UI Toolkit panel delivers; only the What's New popup, when it has to create an EventSystem, picks
InputSystemUIInputModulewhen the Input System is installed and active, elseStandaloneInputModule. - No third-party dependencies, no native code, no shaders.
Installation
From the Asset Store
- Open the Package Manager: Window > Package Manager in Unity 6.0, Window > Package Management > Package Manager in Unity 6.3.
- Select My Assets and find Markdown Viewer.
- Click Install.
Unity installs Markdown Viewer as a package. It appears under Packages > Markdown Viewer in the Project window and its files are read-only. Your own documents, themes and scenes stay under Assets/.
Demo scenes
In the Package Manager, select Markdown Viewer, open the Samples tab and import Demo. Unity copies the sample into your project under Assets/Samples, where you can change it.
| Scene | What it shows |
|---|---|
00 Menu |
Launcher with one button per scene. |
01 Help Screen uGUI |
A help screen in a MarkdownView, set up entirely in the Inspector: a table of contents of #anchor links, a table of controls, lists, a quote and a picture. |
02 Help Screen UI Toolkit |
The same document in a MarkdownElement declared in UXML; a script assigns the source, the theme and an image resolver. |
03 Whats New |
A WhatsNewPopup on an example changelog, with buttons to show what is new, show every version, pretend an older version was seen and forget the stored version. |
04 Live Editor |
An input field on one side and a MarkdownView on the other, updated as you type. |
05 Showcase |
Every supported element in one document, with buttons to switch the renderer (uGUI or UI Toolkit), the theme (light, dark, Terminal) and the text component (Unity Text or TextMeshPro). |
Things to know:
- The sample scenes use uGUI and Unity's built-in font. Scene
05offers TextMeshPro, which needs the TMP Essential Resources; without them the view logs one warning and keeps Unity Text. - Open any scene from
01to05and press Play. To use00 Menu, first add all six scenes to the Scene List in File > Build Profiles, with00 Menufirst. This is needed in Play mode in the Editor as well as in a build, because the menu loads the scenes by name. When a scene is missing, the menu says so on screen. 00 Menuhas a smallluanrobs.com/markdown-viewerline in its footer that opens the product page only when it is clicked. Delete theSite Linkobject to remove it.- A
README.txtinside the sample describes each scene and script.
Quick start: uGUI
Without code
- Create a Canvas from the GameObject menu (its uGUI items are under UI). Unity adds an EventSystem with it; the view needs one to scroll and to receive clicks.
- Under the Canvas, create an empty UI object (GameObject > Create Empty Child, which gets a RectTransform under a Canvas) and give it the size and position you want. Stretched to the full Canvas is a good start.
- Add Component > luanrobs > Markdown View.
- Drag a
.mdfile from the Project window into Source. - Press Play. The document appears, scrolls with the mouse wheel, by dragging and by touch, and its links work.
The view shows nothing in Edit mode: it renders in Play mode only (see Lifecycle and rebuilds).
From code
using Luanrobs.Markdown;
using UnityEngine;
public class HelpScreen : MonoBehaviour
{
[SerializeField] private MarkdownView view;
[SerializeField] private TextAsset helpFile;
private void Start()
{
view.Source = helpFile;
view.Theme = MarkdownTheme.DefaultDark;
view.LinkClicked += OnLinkClicked;
}
private void OnDestroy()
{
if (view != null)
{
view.LinkClicked -= OnLinkClicked;
}
}
private void OnLinkClicked(MarkdownLinkEventArgs link)
{
if (link.Kind == MarkdownLinkKind.Other)
{
Debug.Log("The document links to " + link.Url);
link.Handled = true;
}
}
}
To create the view itself in code, add it to a GameObject that has a RectTransform under a Canvas:
using Luanrobs.Markdown;
using UnityEngine;
public class CreateViewInCode : MonoBehaviour
{
[SerializeField] private RectTransform parent;
private void Start()
{
var target = new GameObject("Markdown", typeof(RectTransform));
var rect = (RectTransform)target.transform;
rect.SetParent(parent, false);
rect.anchorMin = Vector2.zero;
rect.anchorMax = Vector2.one;
rect.offsetMin = Vector2.zero;
rect.offsetMax = Vector2.zero;
MarkdownView view = target.AddComponent<MarkdownView>();
view.Markdown = "# Hello\n\nThis is **Markdown** in uGUI.\n\n- one\n- two\n";
}
}
Quick start: UI Toolkit
In UXML
Declare the namespace and add the element:
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:lr="Luanrobs.Markdown">
<lr:MarkdownElement name="document" markdown="Hello from **UXML**." />
</ui:UXML>
The UXML attributes are markdown, source, theme, apply-theme, scrollable, default-link-handling and load-images-from-resources. source (a TextAsset) and theme (a MarkdownTheme) are asset references; set them in UI Builder or in code. The demo scene 02 keeps its UXML minimal and assigns them from a script:
using Luanrobs.Markdown;
using UnityEngine;
using UnityEngine.UIElements;
public class ToolkitHelpScreen : MonoBehaviour
{
[SerializeField] private UIDocument document;
[SerializeField] private TextAsset helpFile;
[SerializeField] private MarkdownTheme theme;
private void Start()
{
MarkdownElement element = document.rootVisualElement.Q<MarkdownElement>("document");
element.Source = helpFile;
element.Theme = theme;
}
}
From code
using Luanrobs.Markdown;
using UnityEngine;
using UnityEngine.UIElements;
public class ToolkitFromCode : MonoBehaviour
{
[SerializeField] private UIDocument document;
[SerializeField] private TextAsset helpFile;
private void Start()
{
var element = new MarkdownElement();
element.Source = helpFile;
element.LinkClicked += link => Debug.Log("Clicked " + link.Url);
document.rootVisualElement.Add(element);
}
}
The element has flex-grow: 1 by default, so it fills the space its parent gives it and scrolls inside it.
Quick start: What's New popup
- Keep a changelog in the Keep a Changelog style (
## [1.2.0] - 2026-09-30headings) as a.mdfile in your project. - Add Add Component > luanrobs > What's New Popup to any GameObject of your first scene (it needs no Canvas).
- Drag the changelog into Changelog and set Player Prefs Key to a key of your own game.
- Press Play. The first time, nothing is shown and the latest version is stored (turn on Show On First Run to show the latest version instead). After you release a new version, a returning player sees the versions they have not seen, and closing the popup stores the new latest version.
A "Release notes" button can show every version:
using Luanrobs.Markdown;
using UnityEngine;
public class ReleaseNotesButton : MonoBehaviour
{
[SerializeField] private WhatsNewPopup popup;
// Call this from the OnClick list of a Button.
public void ShowReleaseNotes()
{
popup.ShowAll();
}
}
Where the text comes from
Both MarkdownView and MarkdownElement have two sources:
Source, aTextAsset. Unity imports.mdfiles asTextAssetout of the box, so any.mdor.txtfile works; no importer is added.Markdown, a string.
Rules:
- In code, the last of the two you assign wins. Assigning
MarkdownsetsSourceto null; assigning a non-nullSourcemakes it the shown source. Assigning null toSourceshowsMarkdownagain. - When both are set in the Inspector (uGUI) or in UXML (UI Toolkit),
Sourcewins. - Null counts as the empty string. An empty source shows an empty document.
WhatsNewPopup.ChangelogandWhatsNewPopup.ChangelogTextfollow the same rules.
The .md file is read through TextAsset.text, so it must be text that Unity can decode (UTF-8 is the safe choice). Line endings \r\n, \r and \n are all accepted.
The uGUI view: MarkdownView
MarkdownView is a component (luanrobs/Markdown View in Add Component) for a GameObject with a RectTransform under a Canvas. It uses plain uGUI graphics with the default UI material and no shader of its own. It was run with the Built-in Render Pipeline only; URP and HDRP were not run.
Inspector
| Field | Default | Description |
|---|---|---|
| Source | none | The Markdown file to show. When set, it is shown instead of the Markdown text below. |
| Markdown | empty | Markdown text to show when Source is empty. |
| Theme | none | Fonts, sizes, spacing and colours. Empty: the built-in light theme (MarkdownTheme.DefaultLight). |
| Text Backend | Unity Text | Unity Text needs no setup. TextMeshPro needs the TMP Essential Resources. |
| Scrollable | on | On: the view keeps its size and scrolls the document inside it. Off: the view takes the height of the document, for use inside your own layout or scroll view. |
| Default Link Handling | on | On: a click on a #anchor link scrolls to the heading and a click on an http or https link opens it in the browser. Off: links only raise LinkClicked. |
| Load Images From Resources | on | On: an image found in neither list below is looked up in Resources folders by its address. |
| Sprites | empty | Sprites for the images of the document, matched by name:  shows the sprite named logo. |
| Textures | empty | Textures for the images of the document, matched by name, searched after the sprites. |
What the view creates
With Scrollable on, the first render adds, as children of the view:
Markdown Viewport: stretched over the view, with aRectMask2Dand anImagein the theme'sbackgroundColorthat receives the drags.Markdown Contentunder it: the document, with aVerticalLayoutGroupand aContentSizeFitter.Markdown Scrollbar: a thin vertical scrollbar whose handle has the theme'sscrollbarColor. It hides itself when the document fits, and is not created when the alpha ofscrollbarColoris 0.
A ScrollRect (vertical only, clamped, with inertia) is added to the view's own GameObject and is available as ScrollRect.
With Scrollable off, Markdown Content is the only child, there is no ScrollRect, and the view reports the height of the document through ILayoutElement (preferredHeight). Inside a layout group, the group sizes it; without a layout group on its parent, the view sets its own height. Its width stays yours. Use this to put a document inside your own scroll view or between other elements of a layout.
The view owns everything it creates and destroys it when it rebuilds or is destroyed. Do not add your own objects under it.
Input and EventSystem
The view never reads input devices and never creates a Canvas, an EventSystem or an input module. Like every uGUI control, it needs an EventSystem in the scene to scroll and to receive clicks. Scrolling comes from the ScrollRect (mouse wheel, drag, touch). A link is a click when the pointer goes down and up on it without becoming a drag, so dragging the document over a link scrolls without opening it.
Scrolling from code
ScrollPosition: 0 is the top, 1 the bottom. Reads 0 and ignores writes when the view is not scrollable, when the document fits, or before the first render.ScrollToTop().ScrollToAnchor("#controls"): moves the heading to the top of the view, or as close as the end of the document allows. Returns false when there is no such heading, when the view is not scrollable or has never rendered.
The UI Toolkit element: MarkdownElement
MarkdownElement is a VisualElement declared with [UxmlElement]. Use it in UXML as <lr:MarkdownElement/> with xmlns:lr="Luanrobs.Markdown", or create it with new MarkdownElement().
| Property | UXML attribute | Default | Description |
|---|---|---|---|
Markdown |
markdown |
empty | Markdown text, shown when Source is null. |
Source |
source |
null | The Markdown file to show. |
Theme |
theme |
null | Null means MarkdownTheme.DefaultLight. |
ApplyTheme |
apply-theme |
true | True: fonts, sizes, spacing and colours of the theme are set as inline styles. False: see below. |
Scrollable |
scrollable |
true | True: the document scrolls inside a ScrollView the element creates. False: the blocks are laid out directly in the element, which takes the height of the document. |
DefaultLinkHandling |
default-link-handling |
true | As for the uGUI view. |
LoadImagesFromResources |
load-images-from-resources |
true | True: an image not found by ImageResolver is looked up in Resources folders. |
ImageResolver |
none | null | Your own image lookup, for example a MarkdownImageList with your sprites. |
The element has no Sprites or Textures list: give it a MarkdownImageList through ImageResolver instead.
Styling with USS
Every element the renderer creates carries a USS class from MarkdownUss, for example luanrobs-markdown__heading, luanrobs-markdown__heading--h2, luanrobs-markdown__code-block or luanrobs-markdown__table-row--header. The full list is in the API reference.
With ApplyTheme true, the theme's values are inline styles, which win over style sheets. Set apply-theme="false" to style the document with your own USS: the element then sets only structural styles (flex directions, column weights, image sizes, text alignment of table columns). The colours of links, of code inside a line and of struck-through text still come from the theme, because they are part of the text itself.
Without ApplyTheme, the scroller keeps the look of your panel theme; with it, the vertical scroller is a thin bar in scrollbarColor, hidden when the alpha of that colour is 0.
Links and layout
A link is a click when the pointer goes down and up on the same link and moves less than 10 pixels in between. The element uses <link> tags and the link tag events of UI Toolkit; it never uses <a href>, so nothing is opened by the text system itself.
ScrollPosition, ScrollToTop() and ScrollToAnchor(anchor) behave as on the uGUI view. When the element has not been laid out yet, a scroll position or an anchor is kept and applied right after its next layout, so calling ScrollToAnchor right after assigning a source works. ScrollView is the scroll view the element created, null when Scrollable is false or before the first render.
The element builds its tree without a panel too, so it can be created and filled before it is added to a UIDocument.
Text components
| Unity Text (uGUI, default) | TextMeshPro (uGUI) | UI Toolkit | |
|---|---|---|---|
| Setup | none; Unity's built-in font | TMP Essential Resources | none; the panel's font |
| Struck-through text | shown in the theme's mutedTextColor (the component cannot draw a line through text) |
real strikethrough | real strikethrough |
| Links | in linkColor, not underlined |
in linkColor, underlined |
in linkColor, underlined |
| Code inside a line | in codeTextColor, without a background |
same | same |
| Code blocks | the theme's monospaceFont, else a monospaced font installed on the device, else the text font |
the theme's tmpMonospaceFont, else the text font with evenly spaced letters |
the theme's monospaceFont, else (with ApplyTheme) a monospaced font installed on the device, else the text font with evenly spaced letters |
Choose the component with MarkdownView.TextBackend (Inspector: Text Backend). With TextMeshPro and no TMP Essential Resources in the project, the view logs one warning per view and per Play session and renders with Unity Text.
Unity Text and UI Toolkit look for these monospaced fonts on the device, in this order, and use the first one installed: Consolas, Menlo, DejaVu Sans Mono, Liberation Mono, Droid Sans Mono, Courier New. The font is loaded from the operating system at run time; it is not part of the package. "Evenly spaced letters" means the code is wrapped in an <mspace=0.6em> tag of the text font, so columns line up; the text engine centres each letter of a proportional font in that fixed width, so narrow letters such as i and l stand apart. For code that looks like code everywhere, assign a monospaced font to the theme (monospaceFont, and tmpMonospaceFont for TextMeshPro).
Fonts of body text and headings: Unity Text uses theme.font, else Unity's built-in font (LegacyRuntime.ttf); TextMeshPro uses theme.tmpFont, else the default font asset of the TextMeshPro settings; UI Toolkit uses theme.font, else the font the element inherits from its panel.
Markup in your text never reaches the text component as markup: <b>, <color=red> and any other tag in a document are shown as written, in all three components.
Themes
A MarkdownTheme is a ScriptableObject that holds the fonts, sizes, spacing and colours of a document. One theme drives both renderers.
- Create an asset with Assets > Create > luanrobs > Markdown Theme. A new theme has the light colours. The context menu of the asset (the three dots in its Inspector header) has Apply Light Preset and Apply Dark Preset, which change the colours only.
- In code:
MarkdownTheme.CreateLight()andMarkdownTheme.CreateDark()return a new instance that you own (destroy it withDestroywhen you no longer need it). MarkdownTheme.DefaultLightandMarkdownTheme.DefaultDarkare shared instances, never saved, recreated at the start of each Play session. A view with no theme usesDefaultLight. Do not change their fields; create your own theme instead.- Sizes and spacing are in canvas units for uGUI (so they follow your Canvas Scaler) and in pixels for UI Toolkit.
- A view reads its theme when it renders. After changing fields of a theme at run time, call
Refresh()on the views that use it.
Fields
| Field | Default | Description |
|---|---|---|
font |
none | Font of the text in Unity Text mode and in UI Toolkit. Empty: Unity's built-in font in uGUI, the panel's font in UI Toolkit. |
monospaceFont |
none | Font of code blocks in Unity Text mode and in UI Toolkit. Empty: see Text components. |
tmpFont |
none | Font of the text in TextMeshPro mode. Empty: the default font asset of the TextMeshPro settings. Exists only when uGUI is installed. |
tmpMonospaceFont |
none | Font of code blocks in TextMeshPro mode. Empty: evenly spaced letters of the text font. Exists only when uGUI is installed. |
fontSize |
16 | Size of body text. At least 1. |
heading1Scale ... heading6Scale |
2, 1.5, 1.25, 1.1, 1, 0.9 | Size of a heading, as a multiple of fontSize. |
codeFontScale |
0.9 | Size of the text of code blocks, as a multiple of fontSize. |
padding |
16 | Space between the edge of the view and the document. |
blockSpacing |
12 | Vertical space between two blocks. |
listIndent |
24 | Width of the column that holds the bullet, the number or the check box of a list item. |
codePadding |
10 | Space between the edge of a code block and its text. |
quotePadding |
10 | Space between the bar of a block quote and its content, and around the content. |
quoteBarWidth |
4 | Width of the bar on the left of a block quote. |
tableCellPadding |
6 | Space between the edge of a table cell and its text. |
tableBorderWidth |
1 | Width of the lines of a table. |
ruleThickness |
2 | Thickness of a horizontal rule. |
backgroundColor |
white | Background of the view. Alpha 0: no background. |
textColor |
#222831 |
Body text, bullets and numbers. |
headingColor |
#11151C |
Headings. |
mutedTextColor |
#6B7280 |
Struck-through text in Unity Text mode, and the description shown in place of an image that was not found. |
linkColor |
#1D5FD1 |
Links, and the inner square of a checked task. |
codeTextColor |
#9A3412 |
Text of code blocks and of code inside a line. |
codeBackgroundColor |
#EEF0F3 |
Background of code blocks. |
quoteTextColor |
#4B5563 |
Text inside a block quote. |
quoteBarColor |
#C9CED6 |
Bar on the left of a block quote. |
quoteBackgroundColor |
#F6F7F9 |
Background of a block quote. Alpha 0: no background. |
tableBorderColor |
#D5D9E0 |
Lines of a table. |
tableHeaderBackgroundColor |
#EEF0F3 |
Background of the header row. |
tableRowBackgroundColor |
white | Background of the odd body rows (first, third...). |
tableAlternateRowBackgroundColor |
#F7F8FA |
Background of the even body rows (second, fourth...). |
ruleColor |
#D5D9E0 |
Horizontal rules, and the outline of the check box of a task. |
scrollbarColor |
black, alpha 0x59 | Handle of the scrollbar. Alpha 0: no scrollbar. |
The colours in the table are the light preset. The dark preset uses a background of #14181F, text #D7DBE2, headings #F2F4F7 and links #6CA8FF, with matching values for the other colours.
GetHeadingSize(level) returns fontSize times the scale of the level (levels below 1 count as 1, above 6 as 6). GetCodeSize() returns fontSize * codeFontScale.
Links
Every click or tap on a link, in both renderers and in the What's New popup, goes through the same steps:
- The view creates a
MarkdownLinkEventArgswith the address (Url) and title (Title) of the link as written in the document, and itsKind. - It raises
LinkClicked. Each subscriber is called on its own; an exception in one is logged withDebug.LogExceptionand does not stop the others. - If no subscriber set
Handled = trueandDefaultLinkHandlingis true, the default handling runs:
Kind |
Address | Default handling |
|---|---|---|
Anchor |
starts with # |
scrolls to the heading with that anchor (ScrollToAnchor) |
Web |
starts with http:// or https:// (any case) |
opens it with Application.OpenURL |
Other |
anything else: mailto:, relative paths such as docs/setup.md, custom schemes such as mygame://shop, an empty address |
nothing |
mailto: links, relative paths and custom schemes only raise LinkClicked. Handle them yourself: for example, load another .md file for a relative path, or open your shop screen for mygame://shop.
using Luanrobs.Markdown;
using UnityEngine;
public class DocumentNavigation : MonoBehaviour
{
[SerializeField] private MarkdownView view;
private void OnEnable()
{
view.LinkClicked += OnLinkClicked;
}
private void OnDisable()
{
view.LinkClicked -= OnLinkClicked;
}
private void OnLinkClicked(MarkdownLinkEventArgs link)
{
if (link.Kind == MarkdownLinkKind.Other && link.Url.EndsWith(".md"))
{
// A relative link to another document: load it from Resources/Docs.
string name = link.Url.Substring(0, link.Url.Length - 3);
TextAsset next = Resources.Load<TextAsset>("Docs/" + name);
if (next != null)
{
view.Source = next;
view.ScrollToTop();
}
link.Handled = true;
}
else if (link.Kind == MarkdownLinkKind.Web)
{
// Keep the player in the game: ask first, or block web links entirely.
link.Handled = true;
}
}
}
The package never opens a web page on its own: only a click on a link (or your own call to OpenLink) can lead to Application.OpenURL, and only for http and https addresses. To block all web links, set DefaultLinkHandling to false, or set Handled for Web links as above.
OpenLink(url) follows a link as if it had been clicked (with an empty title): it raises LinkClicked and then applies the default handling. Use it for your own table of contents or buttons: view.OpenLink("#controls").
Anchors
Every heading has an Anchor, computed as GitHub does: the plain text of the heading in lower case; letters, digits, - and _ are kept; each space or tab becomes -; everything else is removed. A heading with no letter or digit gets section. When two headings would get the same anchor, the later ones get -1, -2 and so on. ## Getting Started! has the anchor getting-started.
ScrollToAnchor and MarkdownDocument.FindHeading accept the anchor with or without #, compare without regard to case, decode percent-encoded characters, and also accept the text of the heading itself (Getting Started).
Images
 shows an image. The address is looked up, in this order:
- The view's
ImageResolver, when you assigned one. - uGUI only: the view's
Spriteslist, then itsTextureslist, by name. - Resources folders, when
LoadImagesFromResourcesis true.
An image that is found is shown at its natural size (the sprite's rectangle or the texture's size, in pixels, shown as canvas units or UI Toolkit pixels), left aligned, and scaled down with its proportions kept when it is wider than the space available. Images are never scaled up. An image that is not found shows its description in italics in mutedTextColor; with an empty description it shows nothing.
An image sits on its own line: a paragraph is split around every image at its top level, so an image in the middle of a sentence ends the line before it and the text continues below it. An image that is the only content of a link ([](#top)) is shown the same way, and a click on it follows the link. An image anywhere else (inside emphasis, inside a link that also has text, in a heading or in a table cell) is shown as its description, in the colour of the text around it.
Built-in resolvers
MarkdownImageListmatches by name, without regard to case: the addressesImages/logo.png,logo.pngandlogoall match the asset namedlogo. The last path segment is used, without query, fragment and extension, percent-decoded. Sprites are searched before textures. This is what theSpritesandTextureslists ofMarkdownViewuse.MarkdownResourcesImageResolverloads withResources.Load:Docs/diagram.pngloadsResources/Docs/diagram, first as a sprite, then as a texture. A leading./,/orResources/and the extension are ignored. With a base path (new MarkdownResourcesImageResolver("Docs")) addresses are relative to that folder. This is whatLoadImagesFromResourcesuses, from the root of the Resources folders.
Only relative addresses are ever loaded. An address with a scheme (https://, file://, data:) or that starts with # is never looked up in Resources, and nothing is ever fetched from a network.
Your own resolver
Implement IMarkdownImageResolver to load images from Addressables, from files you downloaded yourself or from anything else:
using System.Collections.Generic;
using Luanrobs.Markdown;
using UnityEngine;
public class DownloadedImages : IMarkdownImageResolver
{
private readonly Dictionary<string, Texture2D> loaded = new Dictionary<string, Texture2D>();
public void Add(string url, Texture2D texture)
{
loaded[url] = texture;
}
public bool TryResolve(string url, out MarkdownResolvedImage image)
{
if (loaded.TryGetValue(url, out Texture2D texture) && texture != null)
{
image = new MarkdownResolvedImage(texture);
return image.IsValid;
}
image = default;
return false;
}
}
Assign it with view.ImageResolver = resolver;. Resolution is synchronous and happens on the main thread while the view renders. When an image becomes available later, call Refresh() on the view. A resolver that throws is treated as if it had returned false, and the exception is logged. The view never destroys the sprites and textures it shows; they belong to you.
What's New
The popup
WhatsNewPopup (uGUI) is a component that shows the parts of your changelog the player has not seen yet.
| Field | Default | Description |
|---|---|---|
| Changelog | none | The changelog file. When set, it is used instead of the text below. |
| Changelog Text | empty | Changelog text to use when Changelog is empty. |
| Player Prefs Key | luanrobs.markdown.whatsnew.lastSeenVersion |
PlayerPrefs key that stores the last version the player saw. Use one key per game. Empty counts as the default. |
| Show On Start | on | The popup calls ShowIfNew() in Start. |
| Show On First Run | off | What a player with no stored version gets. Off: nothing is shown and the latest version is stored, so a new player is not greeted with old release notes. On: the latest version is shown. |
| Title | What's New |
Title at the top of the popup. |
| Close Button Label | Got it |
Label of the button that closes the popup. |
| Theme | none | Theme of the popup and of its document. Empty: the built-in light theme. |
| Text Backend | Unity Text | As for MarkdownView. |
| Sorting Order | 5000 | Sorting order of the popup's Canvas. Higher values draw on top. |
| Reference Resolution | 1280 x 720 | Reference resolution of the popup's Canvas Scaler (Scale With Screen Size, match 0.5). Sizes of the theme are in these units. |
Changes to these fields take effect the next time the popup opens.
What ShowIfNew() does:
- It returns false and does nothing when the component is not active and enabled, when the popup is already open, or when the changelog has no released version.
- With a stored version: it shows the released versions higher than the stored one, highest first. When there are none it returns false and stores nothing, also when the stored version is higher than the latest (for example after a rollback).
- With no stored version: it shows the latest version when Show On First Run is on; otherwise it stores the latest version and returns false.
ShowAll() shows every released version, whatever the player has seen; use it for a "Release notes" button. HasNewEntries tells what ShowIfNew() would return now, without opening or storing anything. LatestVersion is the highest released version, LastSeenVersion the stored one (both empty when there is none).
When it opens, the popup builds its own Screen Space Overlay Canvas (WhatsNew Canvas, a root GameObject) with a dimmed full-screen background that blocks clicks, a centred panel (at most 720 x 560 units, never more than 90% of the canvas) with the title, a scrollable MarkdownView of the selected versions, and the close button. When the scene has no EventSystem, it creates one for as long as it is open. Then it raises Opened. View is that MarkdownView while the popup is open; its links raise the popup's LinkClicked first.
The latest version is stored when the player closes the popup (the close button or Close()), not when it opens: if the game quits while the popup is open, it is shown again next time. Opened is always followed by exactly one Closed, also when the component is disabled or destroyed while the popup is open, or when its Canvas is destroyed by something else such as a scene change; the version is then not stored.
MarkAsSeen() stores the latest version yourself; ResetSeenVersion() deletes the stored version so that the player counts as new again, which is useful while testing. Both save PlayerPrefs.
The popup has no animation and its scroll area uses unscaled time, so it works while Time.timeScale is 0. In the Editor outside Play mode it never opens by itself.
The popup is uGUI only. In a UI Toolkit interface, use MarkdownChangelog with a MarkdownElement, as below.
The changelog format
MarkdownChangelog.Parse reads a changelog in the Keep a Changelog style:
- A version starts at a level 2 heading (
##) whose text begins with a version number of at least two parts, or withUnreleased, with or without square brackets:## [1.2.0] - 2026-09-30,## 1.2.0,## v1.2.0 (2026-09-30),## [Unreleased]. A bracketed version may be a link:## [1.2.0](https://example.com/compare) - 2026-09-30. - A single number is not a version here:
## 3 things,## v2and## 2026-01-05are body text of the version above them, like any other level 2 heading. - A yanked version is tagged
[YANKED]or(yanked), in any case. - The date is the text after the version and an optional separator (space,
-, en dash or em dash), without surrounding parentheses. It is kept as written and not parsed. - Everything before the first version heading (the title and introduction) is ignored. Headings inside fenced code blocks are not headings.
- The
Unreleasedsection is never shown to players: it is not part ofLatest,GetReleased()orGetNewerThan().
Version rules
A version is: an optional v or V, one to four numeric parts of at most nine digits separated by ., an optional pre-release part after - and optional build metadata after + (both made of ASCII letters, digits, . and -). MarkdownChangelog.IsVersion(text) tells exactly this; surrounding spaces are not allowed.
MarkdownChangelog.CompareVersions(a, b) returns -1, 0 or 1 by the rules of Semantic Versioning:
- Numeric parts are compared as numbers; missing parts count as 0.
1.10is higher than1.9, and1.2equals1.2.0. - A version with a pre-release part is lower than the same version without one:
2.0.0-beta.1is lower than2.0.0. Pre-release identifiers are compared one by one: numerically when both are numbers, a number lower than text, otherwise as ordinal text; a shorter list is lower when all earlier identifiers are equal. - Build metadata and a leading
vare ignored. - Text that is not a version is lower than any version; two such texts are compared as ordinal text without regard to case. Null counts as the empty string.
Release notes in UI Toolkit
using System.Collections.Generic;
using Luanrobs.Markdown;
using UnityEngine;
using UnityEngine.UIElements;
public class ToolkitWhatsNew : MonoBehaviour
{
private const string Key = "mygame.lastSeenVersion";
[SerializeField] private UIDocument document;
[SerializeField] private TextAsset changelogFile;
private void Start()
{
MarkdownChangelog changelog = MarkdownChangelog.Parse(changelogFile.text);
if (changelog.Latest == null)
{
return;
}
string lastSeen = PlayerPrefs.GetString(Key, "");
IReadOnlyList<MarkdownChangelogEntry> unseen = changelog.GetNewerThan(lastSeen);
if (unseen.Count > 0)
{
var element = new MarkdownElement();
element.Markdown = MarkdownChangelog.ToMarkdown(unseen);
document.rootVisualElement.Add(element);
}
PlayerPrefs.SetString(Key, changelog.Latest.Version);
PlayerPrefs.Save();
}
}
GetNewerThan with an empty or invalid version returns every released entry. ToMarkdown turns entries back into one Markdown text: for each entry a level 2 heading (## 1.2.0 - 2026-09-30, with (yanked) for a yanked entry), an empty line and the body. Parse reads that text back to the same entries.
The document tree
MarkdownDocument.Parse(text) turns Markdown into a read-only tree. Every view also exposes the tree of its current source as Document, parsed on first use and again after the source changes or Refresh().
- Blocks:
MarkdownHeading(Level1 to 6,Anchor),MarkdownParagraph,MarkdownBlockQuote,MarkdownList(IsOrdered,Start,IsTight,Items),MarkdownListItem(Task),MarkdownCodeBlock(Code,Info,Language,IsFenced),MarkdownThematicBreak,MarkdownTable(ColumnCount,Alignments,Header,Rows),MarkdownTableRow,MarkdownTableCell. - Inlines:
MarkdownText,MarkdownEmphasis,MarkdownStrong,MarkdownStrikethrough,MarkdownCodeSpan,MarkdownLink(Url,Title,IsAutolink),MarkdownImage(Url,Title,Alt),MarkdownLineBreak(IsHard). - Every node has a
Type(MarkdownNodeType) so you can switch on it. Headingslists every heading of the document, at any depth, in document order.FindHeading(anchor)finds one.
A table of contents from the headings:
using System.Collections.Generic;
using System.Text;
using Luanrobs.Markdown;
using UnityEngine;
public class TableOfContents : MonoBehaviour
{
[SerializeField] private MarkdownView view;
private void Start()
{
foreach (MarkdownHeading heading in view.Document.Headings)
{
if (heading.Level <= 2)
{
Debug.Log(new string(' ', heading.Level * 2) + PlainText(heading.Inlines) + " -> #" + heading.Anchor);
}
}
// A button of your own can then call view.ScrollToAnchor(anchor).
}
private static string PlainText(IReadOnlyList<MarkdownInline> inlines)
{
var builder = new StringBuilder();
foreach (MarkdownInline inline in inlines)
{
if (inline is MarkdownText text)
{
builder.Append(text.Text);
}
else if (inline is MarkdownCodeSpan code)
{
builder.Append(code.Code);
}
else if (inline is MarkdownContainerInline container)
{
builder.Append(PlainText(container.Inlines));
}
else if (inline is MarkdownLineBreak)
{
builder.Append(' ');
}
}
return builder.ToString();
}
}
Shapes of the tree worth knowing:
- Text has backslash escapes and entities resolved. Two
MarkdownTextnodes are never adjacent, and no node text contains\r. - A soft line break (a line ending inside a paragraph) is
MarkdownLineBreakwithIsHardfalse and is drawn as a space; a hard break (two or more spaces, or a backslash, before the line ending) hasIsHardtrue and starts a new line. MarkdownCodeBlock.Codeends every line with\n(an empty block is the empty string); tabs are kept.Infois the trimmed text after the opening fence,Languageits first word. Both are empty for indented code.MarkdownCodeSpan.Codeturns line endings into spaces and strips one leading and one trailing space when both exist.- An autolink is a
MarkdownLinkwithIsAutolinktrue and oneMarkdownTextchild with the address as written. Forwww.example.comtheUrlishttp://www.example.com; for<name@example.com>it ismailto:name@example.com. - In a
MarkdownTable,Alignments,Header.Cellsand theCellsof every row all haveColumnCountentries. MarkdownList.Startis the first number of an ordered list, and 1 for a bullet list.
Constructors of the nodes are internal: the tree is created by the parser only.
Supported Markdown
The dialect is CommonMark 0.31.2 plus the GitHub Flavored Markdown tables, strikethrough, task list items and extended autolinks, with the differences listed in the next section.
| Element | Syntax |
|---|---|
| Headings | # Title to ###### Title, or a line underlined with === or --- |
| Paragraphs and line breaks | blank lines between paragraphs; two spaces or \ at the end of a line for a hard break |
| Emphasis and strong | *em*, _em_, **strong**, __strong__, nested and mixed |
| Strikethrough | ~~struck~~ or ~struck~ |
| Code inside a line | `code`, also with longer backtick runs |
| Links | [text](url "title"), [text][label], [text][], [label] with [label]: url "title" definitions |
| Autolinks | <https://example.com>, <name@example.com>, and bare https://..., http://..., www.... addresses |
| Images | , also with reference labels |
| Block quotes | > text, nested, with lists and code inside |
| Lists | -, +, * bullets; 1. or 1) numbers, with any start number of up to nine digits; tight and loose; nested |
| Task lists | - [ ] to do, - [x] done (also in ordered lists) |
| Code blocks | fenced with ``` or ~~~ (with an info string), or indented by four spaces |
| Tables | GitHub tables with :---, :---: and ---: alignment |
| Horizontal rules | ---, ***, ___ |
| Escapes and entities | \*, numeric references such as # and 😀, and the named references listed below |
Also as in CommonMark: lazy continuation lines, tabs as tab stops of four, multi-line link reference definitions and titles, the delimiter-run rules for emphasis (rule of three included), no links inside links, and the precedence of code spans and autolinks over brackets.
Differences from CommonMark and GitHub
These are deliberate. Everything not listed here follows CommonMark 0.31.2.
- Raw HTML is not interpreted. There are no HTML blocks and no inline HTML.
<only starts an autolink, or is text.<div>*hi*</div>is a paragraph that shows<div>, the word hi in italics and</div>. Tags such as<b>or<color=red>are shown as written; they never reach the text component as markup. - HTML comments are left out. A line that starts (after up to three spaces) with
<!--opens a comment that ends with the line that contains-->, as an HTML block of CommonMark would, and nothing of it is shown. Inside a paragraph,<!--...-->is left out too, also across lines of the same paragraph; without a closing-->in the same paragraph the<!--is shown as text. A comment between two spaces leaves one space (a <!-- b --> cshowsa c), since the text components draw every space. Comments in code are code. - Named entities: a fixed list. Numeric references work as in CommonMark (invalid code points, 0 and surrogates give U+FFFD), except that
gives U+FFFD and gives a space: the text components would draw a line feed as a line break, which HTML does not. Named references are recognised only for:& < > " ' © ® ™ … — – ‘ ’ “ ” « » • · ° ± × ÷ € £ ¥ ¢ § ¶ µ ½ ¼ ¾ ← → ↑ ↓ ↔. Any other&name;stays as written. - Bare addresses.
http://,https://andwww.addresses become links at the start of the text or after whitespace or one of*,_,~,(. GitHub's rules for trailing punctuation and parentheses apply, and<ends the address. Awww.address getshttp://in itsUrl(not in the text). Bare e-mail addresses and other schemes are not linked; write<name@example.com>or<mailto:name@example.com>instead. - Strikethrough uses one or two tildes, the same number to open and to close, with the flanking rules of emphasis. Three or more tildes inside a line are text.
- Tables follow GitHub: a header row and a delimiter row with the same number of cells, both with at least one unescaped
|. Body rows run until a blank line or the start of another block, and are padded with empty cells or cut to the number of columns.\|is a literal pipe, also inside code. A table can follow paragraph text directly; the last line before the delimiter row becomes the header. More than 64 columns: not a table. - Task list items: an item whose first paragraph starts with
[ ],[x]or[X]followed by a space or tab and more text. Otherwise the brackets are text. - Depth limits. Block quotes and list items nest at most 32 deep (counted together): a marker that would open level 33 is text of level 32. Emphasis, strong, strikethrough and links nest at most 32 deep: deeper delimiters stay as text. These limits keep every input safe to parse.
- Info strings of fenced code are stored trimmed and otherwise as written (escapes and entities in them are not resolved).
- Link labels are matched with whitespace collapsed and invariant upper case, instead of full Unicode case folding. Link destinations are stored unescaped and never percent-encoded.
- Unicode. Whitespace is what
char.IsWhiteSpacesays; punctuation for the emphasis rules ischar.IsPunctuationorchar.IsSymbol; a character outside the Basic Multilingual Plane counts as a letter. U+0000 becomes U+FFFD.
Footnotes, definition lists, math, front matter and other extensions are not recognised; their text is shown as ordinary Markdown.
How each element is drawn
Both renderers draw every element the same way, with values from the theme:
- Document:
paddingaround it,backgroundColorbehind it.blockSpacingbetween blocks; a heading that is not the first block gets half ablockSpacingmore above it. - Headings:
GetHeadingSize(level), bold,headingColor. - Paragraphs and list text:
fontSize,textColor; inside a quote,quoteTextColor. - Block quotes: a bar
quoteBarWidthwide inquoteBarColor,quoteBackgroundColorbehind,quotePaddingaround the content. - Lists: a marker column
listIndentwide, then the content. Bullets are•at every depth; ordered items show7.style numbers fromStart. Items of a tight list are a quarter ofblockSpacingapart, of a loose listblockSpacing. - Task items: a square check box instead of the marker, drawn as shapes (not font glyphs): outline in
ruleColor, and an inner square inlinkColorwhen checked. - Code blocks:
codeBackgroundColor,codePadding, text incodeTextColoratGetCodeSize(). Long lines wrap; there is no horizontal scrolling. Tabs become four spaces. No syntax highlighting. - Rules:
ruleThicknesshigh, full width,ruleColor. - Tables: full width; every column is at least as wide as its longest word plus the cell padding, and the rest of the width is shared in proportion to the length of the longest text of each column (clamped so that no column is too narrow or too wide); a word breaks only when the longest words of all columns together do not fit in the width, and then all columns shrink together; all rows have the same column widths; grid lines
tableBorderWidthintableBorderColor; a bold header row intableHeaderBackgroundColor; body rows alternatingtableRowBackgroundColorandtableAlternateRowBackgroundColor;tableCellPaddingin cells; text aligned per column and wrapping inside the cell; the cells of a row share its height. - Images: see Images.
In uGUI every block is one GameObject named after it (Heading, Paragraph, Quote, List, ListItem, CodeBlock, Rule, Table, TableRow, TableCell, Image, ImageMissing), and text sits on children named Text. In UI Toolkit every block is one VisualElement with the matching class of MarkdownUss. These names are stable, but the objects belong to the view: do not change them, they are replaced on every rebuild.
Lifecycle and rebuilds
- Setting a property that changes what is shown marks the view dirty, and the document is rebuilt once: for
MarkdownViewinLateUpdateof the same frame (only while the view is active and enabled in Play mode); forMarkdownElementon the next update of its panel, or when it is attached to a panel. Assigning ten properties in one frame rebuilds once. - A setter marks the view dirty only when the value really changes (the same object, or an equal string, does nothing).
Refresh()parses the source again and rebuilds at once.ScrollToAnchor,ScrollToTopandScrollPositionrebuild first when the view is dirty.- A rebuild keeps the distance scrolled from the top, clamped to the new height. Call
ScrollToTop()after showing another document. - Not detected automatically: changes to the fields of an assigned theme, and changes to the contents of
Sprites,Texturesor a resolver. CallRefresh()after them. MarkdownViewrenders only in Play mode. In Edit mode it shows nothing unlessRefresh()is called; objects created then are marked not to be saved with the scene.Refresh()does nothing while the GameObject is inactive.MarkdownElementbuilds in Edit mode and in Play mode. Without a panel it builds whenRefresh()(or a scroll member) is called, or when it is attached to a panel.
Error handling
No public member throws for bad content or null arguments:
- The parsers accept any string.
MarkdownDocument.ParseandMarkdownChangelog.Parsenever throw and never return null; null and empty text give an empty result. - A render never throws. If building the document fails, the exception is logged with
Debug.LogExceptionand the source is shown as one plain-text paragraph. - An exception in a
LinkClicked,OpenedorClosedsubscriber, or in an image resolver, is logged withDebug.LogExceptionand does not stop the others or the render. - Null arguments count as empty:
OpenLink(null),ScrollToAnchor(null)andFindHeading(null)do nothing or return false or null.
The only warning the package logs on its own: "Markdown View: TextMeshPro mode needs the TMP Essential Resources (Window > TextMeshPro > Import TMP Essential Resources); using Unity Text." It is logged once per view per Play session. Nothing is logged on success.
Threading
MarkdownDocument.Parse, MarkdownChangelog.Parse and the static helpers of MarkdownChangelog (ToMarkdown, CompareVersions, IsVersion) keep no shared state and can be called from any thread, for example to parse a large file on a worker thread. Reading a parsed tree from several threads is safe; it never changes after parsing.
Everything else (the views, themes, resolvers, the popup and the events) must be used from the main thread. Events are raised on the main thread.
Domain Reload
The package works with Enter Play Mode Options set to skip the Domain Reload. Its static state is reset at the start of every Play session (RuntimeInitializeLoadType.SubsystemRegistration): the shared DefaultLight and DefaultDark themes are recreated, and the cached built-in and device monospaced fonts are looked up again. Events are per instance, so a subscriber of a destroyed view cannot be called again. Unsubscribe your own handlers in OnDisable or OnDestroy, as in the examples above.
This was run on Unity 6000.3.12f1: three Play sessions in a row with Domain Reload disabled passed.
Limits and performance
These limits are part of the behaviour, so that any input stays safe to parse and to show:
| Limit | Value | What happens beyond it |
|---|---|---|
| Nesting of block quotes and list items | 32 | The marker is text of the deepest level. |
| Nesting of emphasis, strong, strikethrough and links | 32 | The delimiters stay as text. |
| Table columns | 64 | The lines are not a table. |
| Formatted text of one paragraph, heading or cell | 12,000 characters (counted with the formatting tags the renderer adds) | The element is shown as plain text, without formatting or links. |
| Text given to one text component | 8,000 characters | Longer text, and code blocks longer than this, are split over several text components. |
What was measured, in the Unity 6000.3.12f1 Editor on Windows 11 (2026-10-15):
- 839 EditMode tests, all passed, in 4.4 to 5.4 seconds in total per run (on 2026-10-20, after the last changes, 855 of 855 passed in 6.0 seconds).
- 32 adversarial inputs, most of about 100,000 characters (long runs of
*,_,[,<,&, backticks and<!--, 32-deep quote and list nesting, a flat list of 20,000 items, 10,000 link reference definitions, one line of plain text and others): each was parsed and its tree checked in about 0.23 seconds at most (0.225 to 0.234 seconds in the runs on the final code), the slowest being the flat list of 20,000 items. The test fails above 2 seconds. None of them can overflow the stack: the parsers use no recursion whose depth depends on the input beyond the limits above.
Not measured: render time and memory of the views. The whole document is built at once (there is no virtualisation): every block is one GameObject or VisualElement, and every piece of text one text component. A help screen or a changelog is a small document; a very long document costs memory and layout time in proportion to its length. For long content, split it into several files and show one at a time (for example one per chapter, with relative links handled in LinkClicked).
Platform support
The package is C# only, with no native code and no platform-specific code. Only the platforms in the table below were run.
Tested on
This table lists what was run for version 1.0.0. A platform that says "not run" was not run.
| Platform | Status |
|---|---|
| Windows Editor, Unity 6000.3.12f1 | Run on Windows 11 (2026-10-20): 855 of 855 EditMode tests passed in the development project. |
| Windows player (Mono), Unity 6000.3.12f1 | Run on Windows 11, Direct3D 12 (2026-10-20), in a 1280 x 720 window and in a 450 x 900 window: a test driver walked the six demo scenes through the public API (uGUI with Unity Text and with TextMeshPro, UI Toolkit, light, dark and Terminal themes, anchor links, scrolling, the What's New popup and the live editor), took screenshots and passed with no error logged. Input: the legacy Input Manager; link clicks were simulated inside the engine, not with a real mouse. |
| Clean projects, Unity 6000.3.12f1 and 6000.0.84f1 | Run on Windows 11 (2026-10-20): the package installed from a .tgz archive into a new project created with each version, and the Demo sample imported. On each: 855 of 855 EditMode tests passed, every sample scene opened with no missing scripts, and the test driver passed in a Mono Windows player (Direct3D 12 on 6000.3.12f1, Direct3D 11 on 6000.0.84f1). |
| Windows player (IL2CPP) | Run on Unity 6000.3.12f1 only, from the clean project (2026-10-20): the test driver passed. Not run with IL2CPP on 6000.0.84f1. |
| Android (IL2CPP) | Run on x86-64 emulators only (2026-10-15): a Unity 6000.3.12f1 build (lowest API level 25) on Android 16 (API 36, Vulkan), and a Unity 6000.0.84f1 build (lowest API level 23) on Android 7.0 (API 24, OpenGL ES 3); the test driver passed on both. |
| Android, physical device | Galaxy S23 (Android 16, arm64, Vulkan): the test driver passed (2026-10-20). |
| Without uGUI and the Input System | Unity 6000.3.12f1 (2026-10-20): the package compiles, MarkdownView and WhatsNewPopup are absent as documented, and 796 of 796 EditMode tests passed. |
| Play mode with Domain Reload disabled | Unity 6000.3.12f1 (2026-10-20): three Play sessions in a row passed. |
| Other platforms (macOS, Linux, iOS, WebGL and the rest) | not run |
Also not run: TextMeshPro mode in the clean projects (it was run in the development project with the TMP Essential Resources, on 6000.3.12f1), physical devices other than the Galaxy S23, the Input System UI input module, URP and HDRP.
Limitations
These are known and stated up front.
- Raw HTML is not rendered. Tags are shown as text and HTML comments are left out. See Differences from CommonMark and GitHub for the other deviations (named entities, bare addresses, depth limits).
- Images sit on their own line. An image in the middle of a sentence breaks the line; an image inside emphasis, inside a link that also has text, in a heading or in a table cell shows its description.
- Images come from your project only: sprites and textures you assign, Resources, or your own resolver. Nothing is loaded from the network.
- No syntax highlighting. Code blocks are one colour, and long lines wrap.
- The whole document is built at once (no virtualisation), so very long documents cost memory and layout time.
- A paragraph, heading or cell with more than 12,000 characters of formatted text is shown as plain text.
MarkdownViewrenders in Play mode only. The Scene view shows nothing in Edit mode.- The What's New popup is uGUI. With UI Toolkit, use
MarkdownChangelogand aMarkdownElement. MarkdownViewdoes not create an EventSystem. The scene needs one, as for any uGUI control.- Links that are neither
#anchorsnorhttp(s)(mailto:, relative paths, custom schemes) raiseLinkClickedand do nothing by default. - Changes are not detected in the fields of an assigned theme or in the contents of
SpritesandTextures: callRefresh(). - Unity Text cannot draw a line through text (struck text is dimmed) and does not underline links. TextMeshPro and UI Toolkit do both.
- Not included: footnotes, maths, an Editor preview window for
.mdfiles, editing, text selection and copy, right-to-left and complex-script shaping beyond what the text component does.
API reference
Namespace: Luanrobs.Markdown. Assembly: Luanrobs.Markdown.
If your scripts live in an assembly definition, add a reference to Luanrobs.Markdown.
MarkdownView
public sealed class MarkdownView : MonoBehaviour, ILayoutElement (only when com.unity.ugui is installed)
| Member | Description |
|---|---|
event Action<MarkdownLinkEventArgs> LinkClicked |
Raised when a link is clicked or tapped, and by OpenLink. Set Handled to stop the default handling. |
TextAsset Source { get; set; } |
The Markdown file. A non-null value becomes the shown source. |
string Markdown { get; set; } |
Markdown text. Assigning it clears Source. |
MarkdownTheme Theme { get; set; } |
Null means MarkdownTheme.DefaultLight. |
MarkdownTextBackend TextBackend { get; set; } |
UnityText (default) or TextMeshPro. |
bool Scrollable { get; set; } |
True by default. |
bool DefaultLinkHandling { get; set; } |
True by default. |
bool LoadImagesFromResources { get; set; } |
True by default. |
List<Sprite> Sprites { get; } |
Sprites matched by name. Call Refresh() after changing the list at run time. |
List<Texture> Textures { get; } |
Textures matched by name, after the sprites. |
IMarkdownImageResolver ImageResolver { get; set; } |
Asked before the lists and Resources. Null by default. |
MarkdownDocument Document { get; } |
The parsed current source. Never null. Does not need the view to be active. |
ScrollRect ScrollRect { get; } |
The scroll area the view created; null when not scrollable or never rendered. |
float ScrollPosition { get; set; } |
0 top, 1 bottom, clamped. |
void Refresh() |
Parses again and rebuilds now. Works in Edit mode; does nothing while the GameObject is inactive. |
bool ScrollToAnchor(string anchor) |
Scrolls a heading to the top. False when there is no such heading, when not scrollable or never rendered. |
void ScrollToTop() |
Scrolls to the top. |
void OpenLink(string url) |
Follows a link as if it had been clicked. |
ILayoutElement members |
preferredHeight is the height of the document when Scrollable is false and the view has rendered; every other value is -1. layoutPriority is 1. |
MarkdownElement
public sealed partial class MarkdownElement : VisualElement, [UxmlElement]
| Member | Description |
|---|---|
MarkdownElement() |
Creates an empty element with the class luanrobs-markdown. |
event Action<MarkdownLinkEventArgs> LinkClicked |
As on MarkdownView. |
string Markdown { get; set; } |
UXML markdown. Assigning it clears Source. |
TextAsset Source { get; set; } |
UXML source. |
MarkdownTheme Theme { get; set; } |
UXML theme. Null means MarkdownTheme.DefaultLight. |
bool ApplyTheme { get; set; } |
UXML apply-theme. True by default. |
bool Scrollable { get; set; } |
UXML scrollable. True by default. |
bool DefaultLinkHandling { get; set; } |
UXML default-link-handling. True by default. |
bool LoadImagesFromResources { get; set; } |
UXML load-images-from-resources. True by default. |
IMarkdownImageResolver ImageResolver { get; set; } |
Asked before Resources. Null by default. |
MarkdownDocument Document { get; } |
The parsed current source. Never null. |
ScrollView ScrollView { get; } |
Null when not scrollable, and before the first render. |
float ScrollPosition { get; set; } |
0 top, 1 bottom, clamped. Kept until the next layout when set before one. |
void Refresh() |
Parses again and rebuilds now. |
bool ScrollToAnchor(string anchor) |
True when the heading exists and Scrollable is true; the move happens after the next layout when there has been none yet. |
void ScrollToTop() |
Scrolls to the top. |
void OpenLink(string url) |
Follows a link as if it had been clicked. |
WhatsNewPopup
public sealed class WhatsNewPopup : MonoBehaviour (only when com.unity.ugui is installed)
| Member | Description |
|---|---|
const string DefaultPlayerPrefsKey |
"luanrobs.markdown.whatsnew.lastSeenVersion". |
event Action Opened |
Raised when the popup has opened. |
event Action Closed |
Raised exactly once for every Opened. |
event Action<MarkdownLinkEventArgs> LinkClicked |
Raised for a link of the changelog, before the default handling. |
TextAsset Changelog { get; set; } |
The changelog file; wins over ChangelogText. |
string ChangelogText { get; set; } |
Changelog text; assigning it sets Changelog to null. |
string PlayerPrefsKey { get; set; } |
Null or empty counts as DefaultPlayerPrefsKey. |
bool ShowOnStart { get; set; } |
True by default. |
bool ShowOnFirstRun { get; set; } |
False by default. |
string Title { get; set; } |
"What's New" by default. |
string CloseButtonLabel { get; set; } |
"Got it" by default. |
MarkdownTheme Theme { get; set; } |
Null means MarkdownTheme.DefaultLight. |
MarkdownTextBackend TextBackend { get; set; } |
UnityText by default. |
int SortingOrder { get; set; } |
5000 by default. |
Vector2 ReferenceResolution { get; set; } |
1280 x 720 by default. |
string LatestVersion { get; } |
Highest released version, or empty. The changelog is parsed again on every call. |
string LastSeenVersion { get; } |
Stored version, or empty. |
bool HasNewEntries { get; } |
What ShowIfNew() would return now, without side effects. |
bool IsOpen { get; } |
True while the popup is on screen. |
MarkdownView View { get; } |
The document view while open; null while closed. |
bool ShowIfNew() |
Opens with the unseen versions. True when it opened. |
bool ShowAll() |
Opens with every released version. True when it opened. |
void Close() |
Closes, stores the latest version and raises Closed. |
void MarkAsSeen() |
Stores the latest version and saves PlayerPrefs. |
void ResetSeenVersion() |
Deletes the stored version and saves PlayerPrefs. |
MarkdownChangelog and MarkdownChangelogEntry
public sealed class MarkdownChangelog
| Member | Description |
|---|---|
static MarkdownChangelog Parse(string markdown) |
Never throws, never null. Any thread. |
IReadOnlyList<MarkdownChangelogEntry> Entries { get; } |
Every section in file order, Unreleased and duplicates included. |
MarkdownChangelogEntry Latest { get; } |
The released entry with the highest version (the first in the file on a tie), or null. |
IReadOnlyList<MarkdownChangelogEntry> GetReleased() |
Released entries, highest first; yanked versions included. |
IReadOnlyList<MarkdownChangelogEntry> GetNewerThan(string version) |
Released entries higher than version, highest first. Every released entry for null, empty or not a version. |
static string ToMarkdown(IEnumerable<MarkdownChangelogEntry> entries) |
Entries back to Markdown, ready for a view. Null gives the empty string; null items are skipped. |
static int CompareVersions(string a, string b) |
-1, 0 or 1; see Version rules. |
static bool IsVersion(string text) |
Whether the text is a version number this class understands. |
public sealed class MarkdownChangelogEntry
| Member | Description |
|---|---|
string Version { get; } |
The version without brackets and without a leading v; Unreleased for the unreleased section. |
string Date { get; } |
The date as written, or empty. |
bool IsUnreleased { get; } |
True for the Unreleased section. |
bool IsYanked { get; } |
True when tagged [YANKED] or (yanked). |
string Body { get; } |
The Markdown below the heading up to the next version heading, without blank lines at either end; line endings \n. |
MarkdownTheme
public sealed class MarkdownTheme : ScriptableObject. Public fields: see Fields.
| Member | Description |
|---|---|
static MarkdownTheme DefaultLight { get; } |
Shared light theme, never saved. Do not modify. |
static MarkdownTheme DefaultDark { get; } |
Shared dark theme, never saved. Do not modify. |
static MarkdownTheme CreateLight() |
New instance with the light preset; you own it. |
static MarkdownTheme CreateDark() |
New instance with the dark preset; you own it. |
void ApplyLightPreset() |
Sets every colour to the light preset. Also in the asset's context menu. |
void ApplyDarkPreset() |
Sets every colour to the dark preset. Also in the asset's context menu. |
float GetHeadingSize(int level) |
fontSize times the scale of the level, level clamped to 1..6. |
float GetCodeSize() |
fontSize * codeFontScale. |
MarkdownTextBackend
public enum MarkdownTextBackend { UnityText = 0, TextMeshPro = 1 }
MarkdownLinkEventArgs and MarkdownLinkKind
public sealed class MarkdownLinkEventArgs
| Member | Description |
|---|---|
MarkdownLinkEventArgs(string url, string title) |
Null counts as the empty string. Kind is computed from url. |
string Url { get; } |
The address as written in the document. Never null. |
string Title { get; } |
The title, or empty. Never null. |
MarkdownLinkKind Kind { get; } |
What the link points at. |
bool Handled { get; set; } |
Set to true to stop the default handling. |
static MarkdownLinkKind GetKind(string url) |
Classifies an address; surrounding whitespace ignored, scheme compared without regard to case. |
public enum MarkdownLinkKind { Anchor = 0, Web = 1, Other = 2 }: an address starting with #; with http:// or https://; anything else.
Images
| Type | Members |
|---|---|
public interface IMarkdownImageResolver |
bool TryResolve(string url, out MarkdownResolvedImage image): true when found and valid. url is never null. |
public readonly struct MarkdownResolvedImage |
MarkdownResolvedImage(Sprite sprite), MarkdownResolvedImage(Texture texture), Sprite Sprite, Texture Texture, Vector2 Size (natural size in pixels), bool IsValid (an asset and a non-zero size). |
public sealed class MarkdownImageList |
MarkdownImageList(), MarkdownImageList(IEnumerable<Sprite> sprites, IEnumerable<Texture> textures) (copies the items; either can be null), List<Sprite> Sprites, List<Texture> Textures, TryResolve. |
public sealed class MarkdownResourcesImageResolver |
MarkdownResourcesImageResolver(), MarkdownResourcesImageResolver(string basePath), string BasePath (empty for the root), TryResolve. |
MarkdownUss
public static class MarkdownUss: the USS classes of the elements MarkdownElement creates.
| Constant | Class | Element |
|---|---|---|
Root |
luanrobs-markdown |
the MarkdownElement itself |
Content |
luanrobs-markdown__content |
the element that holds the blocks |
Text |
luanrobs-markdown__text |
every label that shows text |
Heading |
luanrobs-markdown__heading |
a heading |
HeadingLevelPrefix |
luanrobs-markdown__heading--h |
followed by the level: --h1 to --h6 |
Paragraph |
luanrobs-markdown__paragraph |
a paragraph |
Quote |
luanrobs-markdown__quote |
a block quote |
List |
luanrobs-markdown__list |
a list |
ListOrdered |
luanrobs-markdown__list--ordered |
added to an ordered list |
ListItem |
luanrobs-markdown__list-item |
a list item |
ListMarker |
luanrobs-markdown__list-marker |
the column with the bullet, number or check box |
ListContent |
luanrobs-markdown__list-content |
the column with the item's blocks |
Checkbox |
luanrobs-markdown__checkbox |
the check box of a task |
CheckboxChecked |
luanrobs-markdown__checkbox--checked |
added when the task is done |
CodeBlock |
luanrobs-markdown__code-block |
a code block |
CodeText |
luanrobs-markdown__code-text |
the label inside a code block |
Rule |
luanrobs-markdown__rule |
a horizontal rule |
Table |
luanrobs-markdown__table |
a table |
TableRow |
luanrobs-markdown__table-row |
a row |
TableRowHeader |
luanrobs-markdown__table-row--header |
added to the header row |
TableRowAlternate |
luanrobs-markdown__table-row--alternate |
added to the even body rows |
TableCell |
luanrobs-markdown__table-cell |
a cell |
Image |
luanrobs-markdown__image |
an image |
ImageMissing |
luanrobs-markdown__image-missing |
the description shown for an image that was not found |
MarkdownDocument and the nodes
| Type | Members |
|---|---|
public sealed class MarkdownDocument : MarkdownNode |
static MarkdownDocument Parse(string markdown) (never throws, never null, any thread), IReadOnlyList<MarkdownBlock> Blocks, IReadOnlyList<MarkdownHeading> Headings, MarkdownHeading FindHeading(string anchor) (null when none). |
public abstract class MarkdownNode |
MarkdownNodeType Type. |
public abstract class MarkdownBlock, MarkdownInline |
Base classes of blocks and inline nodes. |
public abstract class MarkdownLeafBlock : MarkdownBlock |
IReadOnlyList<MarkdownInline> Inlines. |
public abstract class MarkdownContainerBlock : MarkdownBlock |
IReadOnlyList<MarkdownBlock> Blocks. |
MarkdownHeading : MarkdownLeafBlock |
int Level (1 to 6), string Anchor. |
MarkdownParagraph : MarkdownLeafBlock |
|
MarkdownBlockQuote : MarkdownContainerBlock |
|
MarkdownList : MarkdownBlock |
bool IsOrdered, int Start, bool IsTight, IReadOnlyList<MarkdownListItem> Items. |
MarkdownListItem : MarkdownContainerBlock |
MarkdownTaskState Task (None, Unchecked, Checked). |
MarkdownCodeBlock : MarkdownBlock |
string Code, string Info, string Language, bool IsFenced. |
MarkdownThematicBreak : MarkdownBlock |
|
MarkdownTable : MarkdownBlock |
int ColumnCount, IReadOnlyList<MarkdownColumnAlignment> Alignments (None, Left, Center, Right), MarkdownTableRow Header, IReadOnlyList<MarkdownTableRow> Rows. |
MarkdownTableRow : MarkdownNode |
bool IsHeader, IReadOnlyList<MarkdownTableCell> Cells. |
MarkdownTableCell : MarkdownLeafBlock |
|
MarkdownText : MarkdownInline |
string Text. |
public abstract class MarkdownContainerInline : MarkdownInline |
IReadOnlyList<MarkdownInline> Inlines. |
MarkdownEmphasis, MarkdownStrong, MarkdownStrikethrough : MarkdownContainerInline |
|
MarkdownLink : MarkdownContainerInline |
string Url, string Title, bool IsAutolink. |
MarkdownImage : MarkdownInline |
string Url, string Title, string Alt. |
MarkdownCodeSpan : MarkdownInline |
string Code. |
MarkdownLineBreak : MarkdownInline |
bool IsHard. |
public enum MarkdownNodeType { Document, Heading, Paragraph, BlockQuote, List, ListItem, CodeBlock, ThematicBreak, Table, TableRow, TableCell, Text = 20, Emphasis, Strong, Strikethrough, CodeSpan, Link, Image, LineBreak }
All concrete node classes are public sealed; their constructors are internal.
Troubleshooting and FAQ
The view is empty in the Scene view
MarkdownView renders in Play mode only. Press Play. In Edit mode, Refresh() from a script of your own renders it once, without saving the objects with the scene.
The view is empty in Play mode
Check that Source or Markdown is set, that the view's RectTransform has a size (a stretched view under a zero-sized parent is zero-sized too), and that the GameObject and component are active. The text colour of the default theme is dark: on a dark Canvas background without a theme background, assign a dark theme.
The document does not scroll and links do nothing
The scene has no EventSystem. Uncommon when the Canvas was created from the GameObject menu, which adds one; scenes built from code often lack it. MarkdownView never creates one. Also check that no other raycast target covers the view.
A link to a heading does not scroll
Check the anchor: lower case, spaces as -, punctuation removed (## Getting Started! is #getting-started); duplicated headings get -1, -2. Read view.Document.Headings to see the anchors. A view with Scrollable off cannot scroll; scroll your own scroll view instead.
mailto:, relative or custom-scheme links do nothing
That is the default: only #anchors and http(s) addresses are followed. Subscribe to LinkClicked and handle the others; see Links.
TextMeshPro mode shows Unity Text and logs a warning
Import the TMP Essential Resources: Window > TextMeshPro > Import TMP Essential Resources.
My HTML tags appear as text
Raw HTML is not interpreted, on purpose. Use Markdown for formatting. Colours come from the theme.
An image shows its description instead of the picture
The address was found nowhere. Check, in the order the view looks: your ImageResolver; the Sprites and Textures lists (uGUI), matched by the asset name without extension; then a Resources folder, when LoadImagesFromResources is on ( loads Resources/Docs/map). Web addresses are never loaded. An image inside a heading, a table cell, emphasis or a link that also has text always shows its description.
I changed the theme or the sprite list and nothing happened
Changes inside an assigned theme, and in the contents of Sprites and Textures, are not detected. Call Refresh().
The scroll position jumps when I assign another document
A rebuild keeps the distance from the top. Call ScrollToTop() after assigning a new source.
The What's New popup does not appear
ShowIfNew() shows nothing for a player with no stored version unless Show On First Run is on (it stores the latest version instead), and nothing when the stored version is already the latest. While testing, call ResetSeenVersion() or use a fresh Player Prefs Key. The changelog needs at least one released version heading such as ## [1.0.0] - 2026-10-15; ## Unreleased alone is not enough, and ## 1 is not a version.
The What's New popup is behind my UI
Raise Sorting Order above the sorting order of your other Canvases.
Long text loses its formatting
A paragraph, heading or cell whose formatted text exceeds 12,000 characters is shown as plain text. Split it into several paragraphs.
Support
Email: luanrobs@gmail.com
When reporting a problem, please include your Unity version, the platform, the text backend (Unity Text, TextMeshPro or UI Toolkit), the Markdown that shows the problem, and the Console or Player log output.
Product page: https://luanrobs.com/markdown-viewer/
Manual online: https://luanrobs.com/markdown-viewer/docs/
I maintain and support this package myself. If it saves you time, a review on the Asset Store helps a lot. Thank you.