Search Unity

TextMesh Pro Works great for 90% of what I need it for

Discussion in 'UGUI & TextMesh Pro' started by Smithy5995, Oct 28, 2017.

  1. Smithy5995

    Smithy5995

    Joined:
    Nov 2, 2016
    Posts:
    6
    Whilst this is a great plugin for making text crisp for my main menu scene, I can't quite get it to work with scripts.
    Whether this is because I'm new to Unity and I haven't figured out how to get it to work or because it doesn't have the functionality, it's really quite annoying.
    The problem I'm having is I have a standard text element that displays FPS via a script that uses public variables to attach the text, the problem here is I can't attach the textmesh pro text element to the public variable so I can display the FPS with crisp text.

    Any help would be greatly appreciated as I have the same problem with other text elements.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There are two TextMesh Pro components. One of type <TextMeshPro> designed to replace the old TextMesh and the second of type <TextMeshProUGUI> which is designed to replace the UI.Text component. Most likely you are using the wrong type to assign the text object in your public field via scripting or in the inspector.

    See FAQ Question 9 which covers this topic. There are also several examples included with TextMesh Pro that also include scripts either creating or accessing text object via scripting or the editor. There is even an example of an FPS counter. See Floating Text Example.
     
    Last edited: Oct 28, 2017
  3. Smithy5995

    Smithy5995

    Joined:
    Nov 2, 2016
    Posts:
    6
    Thanks for the reply, I'll have a look into that.