Changing Texts

By Yuanbo Li, 2023 Spring

By Yuanbo Li, 2023 Spring

How can we change texts in VR in unity? Changing texts based on some user input is crucial to the next step of reading: writing.

Example Result:

The text on the virual phone can be changed during interaction. 

Step 1: Prepare Text Changing Script

This is a script I wrote to help changing text based on user input. It takes an input text and apply it to the target object's text.  You may create a new text and changing it.

Step 2: Attach the script

Attach the script to the trigger of the changing text. Select the function "update text" and bind the "phone text" (which is the target text) to the TextMeshPro object you want to change.

The "Text Variable" is the user input, it can be anything. And a trigger can also be attached to it. (So to allow typing or some more advanced techniques).

Step 3: Event Handling

In the event handling, select the function we just wrote. Bind it to the event trigger. (I'm using on-click trigger here).