[SOLVED] Change Simple Text-value in Text Element - not working

HI!

I have some major issues with changing a Text-entity in my project via javascript.

I have created a simple demo project to show what my problem is:
https://playcanvas.com/project/577968/overview/simpletextedit

This is my code in the Initialize-function:
this.app.root.findByName(“Text”).element.text = “Hello world”;

I want “Text” to change to “Hello World” via script… but that seams to be impossible.

I have tried 5 different methods, so now I’m helpless. I do not know what I am doing wrong.

Can someone try to explain to me what I am doing wrong.

Thanks

  • Mike
1 Like

The problem is that you haven’t assigned your changeTest.js script to a script component. So it never executes.

1 Like

Ah, perfect! Thank you! Now it works! I will leave this project open for anyone else who has this issue.

2 Likes