gwaredd / unitymarkdownviewer Goto Github PK
View Code? Open in Web Editor NEWA markdown viewer for unity
License: MIT License
A markdown viewer for unity
License: MIT License
StyleConverter:37-39
public StyleConverter( GUISkin skin )
{
mReference = new GUIStyle[ CustomStyles.Length ];
mWorking = new GUIStyle[ CustomStyles.Length ];
for( var i = 0; i < CustomStyles.Length; i++ )
{
Debug.Log( mReference[ i ] );
Debug.Log( skin );
Debug.Log( CustomStyles[ i ] );
mReference[ i ] = skin.GetStyle( CustomStyles[ i ] );
mWorking[ i ] = new GUIStyle( mReference[ i ] );
}
}
When using UnityMarkdownViewer programmatically (e.g. downloading a .md file as text and then displaying it), images currently can't be properly resolved when the image URLs are relative to the markdown document location.
Would be great if there was a way to specify a base URL where relative URLs are then referred to (for example: a callback to decide for each URL what to do with it).
Example: download https://raw.githubusercontent.com/atteneder/glTFast/main/README.md via UnityWebRequest and display it by passing the text to a new MarkdownViewer.
Expected: can attach a callback for URls or specify the base URL in another way so that relative image URLs work
Actual: getting errors since the relative URLs can't be resolved properly
Right place for such a callback would probably be MarkdownHandleImages.RemapURL
?
Thetextalllookslikethis.
It looks like this is due to GUIStyle.CalcSize()
not counting the trailing space. LayoutBuilder.AddWord()
calls CalcSize()
on a string with a trailing space for each word. But I'm not sure why this used to work. Did the CalcSize() implementation change?
This is a great complement to my https://github.com/TheWizardsCode/DevLogger - a tool for keeping a DevLog from within Unity.
One of the features I need (and will add if/when I figure out how - no promises) is support for Animated GIFs. I post the idea hear in case anyone else is interested and wants to be notified if I ever do it and the code gets merged and more importantly, ask if anyone has any ideas how to get it done.
I've been working on a UIToolkit implementation of Markdig, and I noticed that the Markdig distribution of the dll doesn't work in Unity.
Did you use a custom version of markdig to make it work in unity?
For some reason I couldn't make it work on 2019.2 - nothing gets rendered (default import). Plus some errors pop (about file location) if I try to move the the folder to a subdirectory.
Ideas?
Large documents seem to cause performance issues, e.g. when displaying
https://github.com/needle-mirror/com.unity.render-pipelines.universal/blob/master/CHANGELOG.md
(the Universal Render Pipeline changelog).
It looks like a potential improvement there is that currently no culling happening to the actually visible area (performance gets linearily worse the longer the document is).
Love this, but the version in the asset store doesn't work with Unity 2020, can you update it please to the latest/greatest?
Also, the link in the asset store isn't right.
https://assetstore.unity.com/packages/tools/utilities/markdown-viewer-138882
(Goes to unium).
I noticed these messages when upgrading to 2020
Assets/UnityMarkdownViewer/Editor/Scripts/MarkdownHandleImages.cs(159,17): warning CS0618: 'UnityWebRequest.isHttpError' is obsolete: 'UnityWebRequest.isHttpError is deprecated. Use (UnityWebRequest.result == UnityWebRequest.Result.ProtocolError) instead.'
I also get this, but I don't know if it's related to UMV:
Failed to destroy editor windows: #1
FallbackEditorWindow
UnityEditor.WindowLayout:LoadDefaultWindowPreferences () (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/WindowLayout.cs:72)
Hello, big fan of this package!
I am trying to use your renderer inside a UIElements IMGUI Container, but it results in all text being rendered on the same line:
Any chance you could add support for this? :)
Also, it would be super great if you could publish this repo as a NPM package to github.
Doing so is really easy using Github Actions: https://github.com/marketplace/actions/npm-publish
You would need to add some lines to the package.json
file:
"repository": {
"type": "git",
"url": "https://github.com/gwaredd/UnityMarkdownViewer.git"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/@gwaredd"
}
By publishing it as a GitHub package, it becomes possible for other Unity packages to be set up to depend on this package, which would be very useful for us.
In a md file like this
### English 繁體中文
English 繁體中文
**English 繁體中文**
This is a sentence.
這是一個句子
And it is how it look like in unity inspector
I think its bcuz the font dont support other language ?
so i want to change font that support more language for consistent looking in different language.
thanks for making this great plugin!!
I don't have anything to request or report, I just wanted to thank you for making this. It very quickly made my day easier and is proving very useful in organizing my thoughts.
This is in Unity 2021.3.x
.
The bolded text is implemented using Unity's boldening of a font referenced via GUIStyle but it seems it doesn't work so well with the included SourceSansPro-Light
font.
I think a way to fix this would be to use the SourceSansPro-SemiBold
or SourceSansPro-Bold
to implement bolded text instead of relying on Unity's boldening of an existing font. Probably this means doing the same for italic and italic+bolded.
This would probably require changes to the StyleConverter
class, which currently looks like this:
public GUIStyle Apply( Style src )
{
if( src.Block )
{
return mWorking[ FixedBlock ];
}
var style = mWorking[ src.Size ];
if( mCurrentStyle != src )
{
var reference = mReference[ src.Fixed ? FixedInline : Variable ];
style.font = reference.font; // Set different fonts based on normal/bold/italic/bold+italic
style.fontStyle = src.GetFontStyle(); // Always 'normal' instead of normal/bold/italic/bold+italic
style.normal.textColor = src.Link ? linkColor : reference.normal.textColor;
mCurrentStyle = src;
}
return style;
}
Would be really nice to have a dark skin!
Hi, thanks for the awesome tool! I think this tool was available on Unity Asset Store but I could not find it anymore? Am I missing anything? 😕
Is there a way to render Markdown in a TextMeshPro component?
I'm thinking Markdown -> HTML, but maybe Markdown to something that Unity supports directly?
No answers to this question, which is the same thing: https://forum.unity.com/threads/simple-html-markdown-renderer-for-textmeshpro.838876/
Any thoughts on how to approach this? Would love to leverage this component into the Unity runtime.
Thanks for creating this asset!
It's a lot more sexy than the default text document renderer that ships with Unity ❤
It seems that after rendering a markdown document, if you select a new markdown document (no matter what other markdown document it is), the document rendering fails. So if you are tapping the arrow keys to browse through your markdown files, you'd experience alternating "working/not working" document rendering as you browse through the files. I've added steps to reproduce below :)
Steps to reproduce:
Press up arrow or click the markdown file above it in the Project window. Observe: Does not render document contents.
Press up arrow or click the markdown file above it in the Project window. Observe: Renders as expected.
Press up arrow or click the markdown file above it in the Project window. Observe: Does not render document contents.
Hi!
Is there a chance to have the MdViewer like a component to use it in a EditorWindow?
I have the .md string and it would be cool to have something like
MarkdownViewer.For(myMdAsString).Render();
Is it possible to render a markdown file using this package in a custom script? I'm hoping I can hook this up to my custom editor window so I can avoid writing a translation layer so my markdown files will render properly according to the markdown syntax/style.
Hey there, not much of a problem more like an inconvinience.
Using Unity 2022.2.5.f1. Tried installing via upm from git link. Everything seemed ok in UPM but getting this error whenever I click on .md file. Nothing happens in the preview window (normal text preview):
NullReferenceException: Object reference not set to an instance of an object
MG.MDV.StyleConverter..ctor (UnityEngine.GUISkin skin) (at ./Library/PackageCache/com.mischief.markdownviewer@cc8c569e13/Editor/Scripts/Layout/StyleConverter.cs:44)
MG.MDV.Context..ctor (UnityEngine.GUISkin skin, MG.MDV.HandlerImages images, MG.MDV.HandlerNavigate navigate) (at ./Library/PackageCache/com.mischief.markdownviewer@cc8c569e13/Editor/Scripts/Layout/Context.cs:9)
MG.MDV.MarkdownViewer.ParseDocument () (at ./Library/PackageCache/com.mischief.markdownviewer@cc8c569e13/Editor/Scripts/MarkdownViewer.cs:67)
MG.MDV.MarkdownViewer..ctor (UnityEngine.GUISkin skin, System.String path, System.String content) (at ./Library/PackageCache/com.mischief.markdownviewer@cc8c569e13/Editor/Scripts/MarkdownViewer.cs:34)
MG.MDV.MarkdownEditor.OnEnable () (at ./Library/PackageCache/com.mischief.markdownviewer@cc8c569e13/Editor/Scripts/MarkdownEditor.cs:28)
When I clone straight into packages directory with git few erros popup on first start up but on recompile everything works. Unfortunately the problem with UPM persists no matter how many times I recompile.
It would be nice to just use this as UPM dependency and not bother with 2 installs. But if you consider this small issue, just close this. Thanks and keep up the great work. Love it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.