3D TextMesh not updating on .text change

Hi,

I’ve read a few answers that seem related to this, but the answer I see given a lot is not working for me.

I have a script that declares a var of type TextMesh (I have also done this with a var od type GameComponent, and then used GetComponent to get a reference to the TextMesh, but the problem remains)

When I update the TextMesh by setting the .text field to a new value, it does not update at runtime. However, once I stop the scene from running the text is updated within the editor!

I have seen references to issuing .Commit(), but I believe that is for 2d work? - TextMesh does not have a .Commit() method.

The only answers I can find on the net just say to update TextMesh.text . For me, that doesn’t work - the mesh is not updated in the game, but it is in the editor. Windows 7 (I’ve seen one reference to a bug in Android that has a similar behaviour)

Does anyone know whats going on?

You are probably changing the Asset (the real prefab, in Project) and not the actual gameObject. When you click on script variable prefabScoreText in the Inspector, Unity should be pulsing the scoreText in the scene.

In general, if you plan to run Instantiate, the link should go to the “real” prefab, from the Project folder. If you plan to change values, the link should be to an already made object (and you almost never Instantiate and change the same thing.)

The terminology is a little confusing. The Asset, in the Project folder is the real prefab. When you drag it into a scene, you might refer to the new object as a “prefab chair.” But, during play, it’s just a regular gameObject. The magic link to the prefab is only to help during editing (which is why you aren’t seeing your real score change.)