CanvasRenderer/TMP issue since updating Unity

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

CanvasRenderer/TMP issue since updating Unity

Post by marafrass »

Heya,

This is most likely a Unity-specific issue, but I figured I'd troubleshoot it here in case anyone's come across the same problem.

I recently updated my project to Unity 2022.3.20f1 (alongside the Adventure Creator 1.81.6 and Dialogue System 2.2.47 updates) and it's a pretty sizable jump in versions. I've managed to get just about everything working just fine, but my Dialogue Manager and Dialogue UI template are having some problems.

My Dialogue UI uses both Unity Text and TMP; the former for the Response Panel and the latter for all lines accumulated in the Scroll Content object. Unity Text works fine, but after updating all versions, the dialogue in the accumulating box is blank and I get this error message:

Code: Select all

MissingComponentException: There is no 'CanvasRenderer' attached to the "TMP UI SubObject [FiraSans-Regular SDF Material]" game object, but a script is trying to access it.
You probably need to add a CanvasRenderer to the game object "TMP UI SubObject [FiraSans-Regular SDF Material]". Or your script needs to check if the component is attached before using it.
TMPro.TMP_SubMeshUI.UpdateMaterial () (at <eb02583e0506474e930bf2dac9e69d51>:0)
TMPro.TMP_SubMeshUI.SetMaterialDirty () (at <eb02583e0506474e930bf2dac9e69d51>:0)
UnityEngine.UI.MaskableGraphic.OnDisable () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/MaskableGraphic.cs:185)
TMPro.TMP_SubMeshUI.OnDisable () (at <eb02583e0506474e930bf2dac9e69d51>:0)
I assume there's something in how Unity (and maybe TMP) handles certain components that's changed, but just in case it's something affected by the Dialogue System, I figured I'd ask. The TextMeshPro Text object does have a CanvasRenderer component, so I assume it's something in the code or compatibility that's causing the issue. If anyone's got any idea of what might be causing it, or has dealt with a similar issue, let me know!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by Tony Li »

Hi,

I haven't seen that error before. Have you tried updating TextMesh Pro in the Package Manager?

You could also try deleting the TMP GameObject, adding a new one, and assigning it to the subtitle panel component. Maybe something's borked with the existing TMP GameObject.
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by marafrass »

I tried updating TMP in the package manager, but that caused a whole avalanche of compile errors so I rolled back for now. Luckily, I was able to isolate the particular issue I was having; I was using a Rich Text tag in the Speaker Name Format box to change the font, and for some reason Unity was unable to make that work correctly which in turn caused the bug and error message I shared. Removing that for now solves the issue mostly, but I'm still dealing with seemingly random instances where certain dialogue lines are not displayed which in turn causes the response option text to disappear, too. I'll take another look at it with fresh eyes tomorrow, and will hopefully have some more specific issues to troubleshoot by then!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by Tony Li »

Hi,

Sounds good. Check the Sequence fields on those dialogue lines.
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by marafrass »

I'm having trouble determining what exactly causes the issue; here's what I've found so far.

Whenever the Dialogue UI breaks, I get this error message:

Code: Select all

MissingComponentException: There is no 'CanvasRenderer' attached to the "TMP UI SubObject [CrimsonText-Regular Material + LiberationSans SDF Atlas]" game object, but a script is trying to access it.
You probably need to add a CanvasRenderer to the game object "TMP UI SubObject [CrimsonText-Regular Material + LiberationSans SDF Atlas]". Or your script needs to check if the component is attached before using it.
TMPro.TMP_SubMeshUI.UpdateMaterial () (at <eb02583e0506474e930bf2dac9e69d51>:0)
TMPro.TMP_SubMeshUI.SetMaterialDirty () (at <eb02583e0506474e930bf2dac9e69d51>:0)
TMPro.TMP_SubMeshUI.RecalculateMasking () (at <eb02583e0506474e930bf2dac9e69d51>:0)
TMPro.TMP_SubMeshUI.OnEnable () (at <eb02583e0506474e930bf2dac9e69d51>:0)
UnityEngine.GameObject:AddComponent()
TMPro.TMP_SubMeshUI:AddSubTextObject(TextMeshProUGUI, MaterialReference)
TMPro.TextMeshProUGUI:SetArraySizes(Int32[])
TMPro.TMP_Text:ParseInputText()
TMPro.TextMeshProUGUI:OnPreRenderCanvas()
TMPro.TextMeshProUGUI:Rebuild(CanvasUpdate)
UnityEngine.Canvas:SendWillRenderCanvases()
I went through the Dialogue Manager and reworked template I'm using just to see if I have any text objects using LiberationSans SDF, but there's nothing there. I initially solved the problem by removing the font tag from Add Speaker Name Format, but now it's popping up in certain dialogues and always at the same spots. There's nothing in the Sequence fields that seems to cause this either - playing voice lines and calling AC action lists don't cause any problems. Similarly, conditionals seem to work just fine.

One theory I had was that it seemed like older dialogues (ones I've written using older versions of the tool) seem to break a lot more than the new ones. I can start and finish a conversation with character A in one instance, for example, but in another conversation with the same character, the UI breaks. Could there be something in how recent versions of Dialogue System sends/reads dialogue data that could cause this issue? I was considering running the 1x to 2x updater to see if that solves the issue, but I wanted to check with you before potentially causing any more damage to the project, since I'm not 100% certain on what exactly that updater does.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by Tony Li »

If you're already on Dialogue System v2.x, don't run the updater.

Check the fallback fonts.

If that doesn't help, have you tried closing your project, deleting the Library folder, and then opening the project and letting Unity rebuild the Library folder?
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by marafrass »

Fallback fonts didn't seem to do the trick, unfortunately.

This is what the error directs to, by the way;
Image

Are these subObjects being created by DS's design? Is there something here that looks wrong to you, immediately? I'm confused by the fact that LiberationSans appears, since I'm not using it anywhere in the Dialogue Manager as far as I can tell.

Will try a full re-import of TMP and/or deleting the Library folder next, just to see if that does the trick.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by Tony Li »

Hi,

Those subobjects are created by TMP. DS has nothing to do with them.
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by marafrass »

Got it! Alright, in that case I'll try to figure this out on the TMP end of things. I'll post a solution here in case I find it, just in case someone else ends up having this issue. Thanks either way for the help and suggestions with troubleshooting!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: CanvasRenderer/TMP issue since updating Unity

Post by Tony Li »

Just had a thought: Those subobjects aren't there outside of play mode, are they? TMPro creates them at runtime when it creates the meshes it uses to render the text. If they're still present outside of play mode, then that might be an issue.
Post Reply