Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved SetText of TextMeshProUGUI component through Visual Scripting

Discussion in 'UGUI & TextMesh Pro' started by Fiti40, Jul 10, 2021.

  1. Fiti40

    Fiti40

    Joined:
    May 25, 2017
    Posts:
    2
    Been trying to get this one to work, but can't seem to get it going.

    So far, I've find out that there doesn't seem to be a way to access TextMeshProUGUI type components other than using a GetComponent with a string input for the type. Here's a pic of what I mean:

    upload_2021-7-10_19-44-46.png

    The one above will return the component correctly, but the one below won't accept anything other than the regular Text Mesh component type. It's like the UGUI type doesn't exist... which I find really weird.

    And then, the thing that I can't find a way to work around is that there's no operation to Set UGUI Text anywhere, only for the non UGUI type. And for the standard unity text components too of course, but those don't exist to me anymore. TMP rules all.

    upload_2021-7-10_19-49-55.png

    This is the only function for TMP Set Text on visual scripting, and it's the non UGUI version. So... I'm stuck.

    I guess I could write a normal boring text based script and do it that way, but mixing code and visual scripting would irk me to no end, so... help me?
     
    Lefko likes this.
  2. Fiti40

    Fiti40

    Joined:
    May 25, 2017
    Posts:
    2
    It turned out to be a stupid thing, as usual. Visual Scripting doesn't support TMP by default, so to get them working together you'll need to update it's assembly definitions list through Edit > Project Settings > Visual Scripting.

    Just add Unity.TextMeshPro to the Node Library, click regenerate, and it's ready to use.

    By the way, if this helps someone, do let me know... would help me feel less stupid.
     
  3. stlouis4d

    stlouis4d

    Joined:
    Jul 19, 2015
    Posts:
    34
    @Fiti40 Definitely helped me, so thanks a million for sharing your solution, as it was the fix I needed to get back on track with my Unity project. Hopefully this helps you feel less stupid for sharing your struggles because we all have them, and it's people like you that help countless others (like me) get past obstacles in their own journey to integrate all of the various parts and pieces of Unity that really should just work properly together right out of the box. So, kudos, Fiti40!
     
    LordVise likes this.
  4. unity_fp2ynxMRi5Kx6g

    unity_fp2ynxMRi5Kx6g

    Joined:
    Jan 16, 2022
    Posts:
    1
    tmp_text set text is the one that ive used after adding Unity.TextMeshPro to change the InputField.
    Thanks Fiti40!
     
  5. Lefko

    Lefko

    Joined:
    Jan 5, 2020
    Posts:
    18
    Thank you Fiti40 so much! I worked on this several hours last night and was so frustrated. I really appreciate both your detailed description of the problem and your simple solution. Thank you!!
     
  6. Elidrin

    Elidrin

    Joined:
    Nov 4, 2021
    Posts:
    6
    This should be stickied. I am really suprised that since the latest LTS patch puts all the nonTMP as legacy that TMP was not supported in Visual Scripting natively.
     
  7. LordVise

    LordVise

    Joined:
    Aug 1, 2020
    Posts:
    7
    Really Helpful. Thanks!