Using textmeshpro for Text 101

I would like to use the Text 101 Adventure Game as a continuing project that I am constantly developing as I go through the 2D course.

I just finished the module in Number Wizard UI that showed me how to serialize the TMP field and display something through code. I would like to use this to kind of polish what I have in my adventure game but I’m not quite sure how to make it pull the text that I have displayed in my “states”.

Question 1: Am I getting too over anxious and I will learn how to use this feature more as the 2D unity course progresses? (I have tried to do a Google search on this but was overwhelmed with what I found as I’m still pretty new to writing code).

Question 2: If it is possible with the knowledge up to lecture 42, could someone please point me in the direction of how to find the solution?

Hi @kittyoffreedom,

Welcome to our community! It’s great to see that you would like to challenge yourself. That’s the best way to learn. :slight_smile:

#1: Which feature are you referring to? Generally, there are just a few concepts which get used over and over again. When you see code, you mainly see different names but the underlying concepts are the same. A variable is still a variable, no matter if it’s named abc or veryImportant. The same goes for methods. As long as you understand the concept/idea, you will be able to apply it. The concept is not bound to a specific programming language or game engine. The programming language is just a way to express a logic, just like you would use English or any other language to express your thoughts/ideas.

#2: I still don’t know what exactly you would like to do but we use the State objects to hold data, and we do not modify those objects. That’s crucial because if we manipulated the State objects during runtime, the changes would persist even after we stopped the game.

the TMPUGUI the toString() method to be specific. But since I’m not trying to display an integer. I just want to use Text Mesh Pro to manipulate the font of the text of my game. The text is in the serialized field of my states. Screenshots of what I’m trying to access in the states with text mesh pro.
State screenshot

The storyText variable is of type string, isn’t it? If so, the data is just a sequence of character without any font design. TextMeshPro needs a string and a font. ToString() is not necessary because you already have the required data. Given I understood your problem correctly, there is no need to edit the State script.

TMP cannot access anything. Your script/object can. In our original class/object (State), we access the Text object. Access the TextMeshProUGUI object instead. Codewise, it works the same way. You just replace the Text type with TextMeshProUGUI and use the TMPro namespace.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms