How create a TextItem() in code?

Other than using the ‘Depreciated’ code I can not create a text object. I’ve spent an hour in the Scene and TextItem Docs and searched the forum to no avail:(

My attempt just generates the attached error…

Debug.log("Error Below:");

//let xxx = Scene.createText(0,2,0, "Hello World");
//xxx.fontSize = 100;
let yyy = new TextItem();

Console output:
Error Below:
classes.js:25 Error occurred loading module ‘play/TypeScript’. Resolution path: play/TypeScript
classes.js:25 java.lang.RuntimeException: (JavaScript) TypeError: Cannot read prope

Hi @jlfjlf,

the updated version fo the method would be with Vector3 item as a parameter to set the initial position.

Scene.createText(new Vector3(0, 2, 0), "Hello World")

Unfortunately, due to a bag in a documentation web site, updated methods do not listed by default.
You need to check the Deprecated box in the upper right corner.

Than you will be able to see all the deprecated methods with they updated counterparts.

Sorry for inconvenience,


1 Like

Oh Man! I wasted so much time:(

Thank you for the answer @llya.Shkuratov

That’s a pretty major bug :open_mouth: So how can we find out if the method/property is updated or deprecated, @Ilya.Shkuratov ? (apart from trial & error)

For the most of the part it should be fine, since the deprecated methods are typically do not shown in completion, so you won’t stumble upon them during coding.

The exception to this is the cases similar to createText, when the method name stays the same but the signature is changed. In this case one can find an updated version next to deprecated one in the documentation.

For cases when the method was moved or renamed, the documentation usually mentions updated counterpart, if the method was actively used, like distanceTo.

1 Like