UnityMarkdownViewer icon indicating copy to clipboard operation
UnityMarkdownViewer copied to clipboard

Markdown Viewer doesn't render any spaces in Unity 2023.1 or later

Open mikehofm opened this issue 1 year ago • 3 comments

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?

mikehofm avatar Dec 01 '23 05:12 mikehofm

It looks like the implementation of CalcSize() has changed in Unity.

I have attached a quick work around as a pull request to this issue. However, it is not clear to me whether this is an intentional change in behaviour or a bug, given 2023.2+ are all in beta.

So I am reluctant to merge this in (or actually write a better fix and not hardcode the values) right now. What do you reckon?

gwaredd avatar Dec 05 '23 16:12 gwaredd

Ah OK, looks like it was a bug with Unity. Maybe I should have checked there first :)

https://issuetracker.unity3d.com/issues/text-in-the-inspector-window-appears-with-missing-spaces-when-using-guistyle-dot-calcsize-and-inspecting-a-file-in-the-inspector-window

This has been fixed in 2023.3.

gwaredd avatar Dec 05 '23 16:12 gwaredd

Actually, I'm going to keep this issue open for now to keep track of it until Unity actually release the fix.

gwaredd avatar Dec 05 '23 16:12 gwaredd