gwaredd / UnityMarkdownViewer

A markdown viewer for unity
MIT License
250 stars 34 forks source link

Not working with UPM #30

Closed clownmeister closed 1 year ago

clownmeister commented 1 year ago

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.

gwaredd commented 1 year ago

Thanks for raising the issue, I suspect the upm branch is out of date. I shall take a look when I get a moment.

gwaredd commented 1 year ago

Ah I forgot this project doesn't have a separate branch for upm :)

If I import UMV into an empty project with openupm add com.mischief.markdownviewer it works fine for me without any compilation or runtime errors. I tried in 2022.3.5f1 which is slightly newer but I doubt it makes a difference as this appears to be a packing issue and not anything to do with the underlying code.

Interestingly, upm was using an older version of the code. I presume they cache the package based on either the version number in the package manifest or repository tag, so I've bumped both and it is using the latest code now.

However, both the old and new code worked fine for me in the latest editor. Possibly then your issue could be with a local cached version of the package or less likely, conflicts within your project.

If you try clearing your cache and you are still getting issues importing into an empty project then just reopen this issue and I'll see what I can do.

clownmeister commented 1 year ago

Thank you so much. Not a day went by when I opened markdown files in my inspector, being pissed that it's not included in the base editor. Keep up the good work and have a great day!

Edit: It works without an issue now :D