unity-game-enginetextmeshpro

Unity - cannot set text in Text Mesh Pro - Missing target object for 'TMPro.TextMeshPro.text'


I'm using Visual scripting in Unity 2021.3.5f1, where want to set a text in Text Mesh Pro using Script graph. When I create a Text Mesh Pro using Game Object > 3D Object > Text - Text Mesh Pro menu items, I can set the text using a Script graph. However, the Text Mesh Pro is not in the Canvas and does not scale by default.

enter image description here

Bodovi is the name of Text Mesh Pro.

I added another Text Mesh Pro object using Game Object > UI > Text - Text Mesh Pro menu path, it is added in Canvas but when I try to use the same script, I'm getting the following error:

InvalidOperationException: Missing target object for 'TMPro.TextMeshPro.text'.
Unity.VisualScripting.Member.EnsureReady (System.Object target) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Reflection/Member.cs:802)
Unity.VisualScripting.Member.Set (System.Object target, System.Object value) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Core/Reflection/Member.cs:842)
Unity.VisualScripting.SetMember.Assign (Unity.VisualScripting.Flow flow) (at Library/PackageCache/com.unity.visualscripting@1.7.8/Runtime/VisualScripting.Flow/Framework/Codebase/SetMember.cs:117)

Switching back to previous Text Mesh Pro object created with Game Object > 3D Object > Text - Text Mesh Pro works fine.

I see that thee two Text Mesh Pro objects have different components in inspector, but I don't see what is the difference that cna cause this error.

The components in Text Mesh Pro that fails:

enter image description here

The components in Text Mesh Pro that succeeds:

enter image description here


Solution

  • I found the solution. The one that didn't work was Text Mesh Pro UI, so I had to use another block - Text Mesh Pro UGUI Set Text:

    enter image description here