Forum Discussion
Anonymous
11 years agoDisplay a variable with 3D Text
Hi,
i would like to display a variable in a 3D text like :
I try with textmesh, but with no success.
Have you got a simple script in javascript ?
Thanks in advance.
i would like to display a variable in a 3D text like :
var score = 100;
I try with textmesh, but with no success.
Have you got a simple script in javascript ?
Thanks in advance.
6 Replies
Replies have been turned off for this discussion
- hash280689Honored GuestThere are a couple of ways you can do this.
If you create a text mesh in the editor, then position it where you want it in front of your camera. Then make the 3d Text mesh a child of the right camera.
To reference it with 'TextMesh'. So you could for example do
"public TextMesh tm", or "[Serializable Field] private TextMesh tm".
Then just do:
tm.text = score;
whenever you need to update the score - AnonymousThanks you, i'll try this asap !
- hash280689Honored GuestNo worries. Also I just realised I gave you a C# solution.
I think the javascript alternative is "@SerializeField private var tm:TextMesh" - AnonymousHi, i try this but no effect :
I create a 3D text with by default text value "hello world".
Then i do this script :@SerializeField private var tm:TextMesh;
var score = 100;
function Update () {
tm.text = score;
}
But the text stay "hello world" instead of the value of my variable score : 100.
Any idea ? thanks ! - hash280689Honored GuestIn the actual editor, did you remember to 'drag' your 3D text mesh into your script?
If you look at your script in the editor, it should show your variable 'Tm' with the phrase "None (Text Mesh") next to it. Just drag your 3dTextMesh into that area and you should be good to go.
Like I said this is one way of accessing your 3d Text Mesh component. This will at least get things working.
Hope this helps - AnonymousIt's OK , i drag 3d text in the tm area.
Thanks a lot !
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device