You can also manually use the parser to convert a Markdown text into a TextAsset or a string in RichText format to display it with
TextMeshPro.
using MarkdownToUnity.Runtime;
UnityUIMarkdownTextAsset asset = MarkdownUnityParser.ParseMarkdown(markdownText);
The asset contains all the elements to be rendered. Example functions can be found in the MarkdownUnityRenderer class.
For asynchronous calls, you can use coroutines or UniTask:
using MarkdownToUnity.Runtime;
// One instance per place you render into - it holds the current render
// state, so don't share a single instance across simultaneous renders.
private readonly MarkdownUnityRenderer renderer = new MarkdownUnityRenderer();
private IEnumerator Test(TextAsset markZip, string languageMarker)
{
if (spinner != null) spinner.SetActive(true);
Task<UnityUIMarkdownTextAsset> parseTask = MarkdownUnityParser.ParseMarkdown(markZip, languageMarker);
yield return new WaitUntil(() => parseTask.IsCompleted);
if (parseTask.IsFaulted)
{
Debug.LogError($"Exception: {parseTask.Exception?.InnerException?.Message}");
}
else
{
UnityUIMarkdownTextAsset asset = parseTask.Result;
if (asset != null)
{
renderer.Render(asset, content, textPrefab.gameObject, horizontalLinePrefab, blockquotePrefab, codeBlockPrefab);
// Or your own rendering logic
}
}
if (spinner != null) spinner.SetActive(false);
}
MarkdownUnityRenderer is a plain class, not static — each instance owns its own style settings and render state, so several can render or stream independently at the same time without interfering with each other.

