"textContent.replace is not a function" error when creating prefab with Legacy Text component

three-mesh-ui.module.js:680

   Uncaught TypeError: textContent.replace is not a function
at collapseWhitespaceOnString (three-mesh-ui.module.js:680:30)
at Text.calculateInlines (three-mesh-ui.module.js:5072:38)
at Text.parseParams (three-mesh-ui.module.js:5002:8)
at UpdateManager.traverseParsing (three-mesh-ui.module.js:1861:14)
at three-mesh-ui.module.js:1844:32
at Array.forEach (<anonymous>)
at UpdateManager.update (three-mesh-ui.module.js:1844:10)
at Module.update (three-mesh-ui.module.js:6381:36)
at MeshUIHelper.update (EventSystem.ts?v=8b13f322:473:33)
at EventSystem.ensureUpdateMeshUI (EventSystem.ts?v=8b13f322:40:22)

message.txt
message.txt
message.txt
message.txt

Original Post on Discord

by user 563549194137239552

How exactly is your setup?

this works because i took the Text component out of the prefab

by user 563549194137239552

image.png

by user 563549194137239552

weird because I added a text and canvas to the synccamera prefab and it shows up without error

by user 563549194137239552

the error above is happening probably because it’s trying to add the annotation prefab when i do a refresh on the page because i am trying to make it a synced objecty

by user 563549194137239552

I am adding annotations to objects when you click on them… I am using instantiate… the annotation is currently just a tiny sphere but i want to add text to it… I am adding the prefab as a child of the object you clicked on where you clicked it… this error is happening as soon as i add the prefab if it has a Text component in it… Legacy text component from unity

by user 563549194137239552

I did almost the same with the existing SyncedCamera prefab qand it shows the text without an error

by user 563549194137239552

If i leave a copy of the prefab in the scene it works fine with no error including the text… if i take the text component out of the prefab i can instantiate it… if i leave the text in it craps out

by user 563549194137239552

this is how I am adding it

                console.log("Add annotation")
                if (this.annoPrefab) {

                    if ("uri" in this.annoPrefab) {
                        let newObj = 
                            this.annoPrefab.instantiate(found.object).then((result) => {
                                console.log(result)
                                if (result)
                                {
                                    let p = result.worldToLocal(found.point)
                                    result.position.set(p.x, p.y, p.z)
                                }
                            })
                        }
                }

by user 563549194137239552

Changed the channel name: “textContent.replace is not a function” error when creating prefab with Legacy Text component

by user 563549194137239552

Using the latest version of needle tools, clean project (collaborative sandbox), simplest possible configuration to reproduce this bug and it still happens. Basically I can’t create a prefab with a Legacy text object in it. I still get the same error as i posted above… I can provide a complete, minimal sample project. There is one script here and all it does is try to create a prefab with a text object in it when you control click somewhere.

I have tried using a prefab from in the scene as well as from a prefab in the file system. I can send the complete project and script if you want. This seems like a pretty critical issue… creating prefabs with embedded world space canvases seems like a pretty common need.

What’s weird is the prefab is in the scene and visible at startup with no issues. It’s only when trying to instantiate it as a prefab that the error occurs.

by user 563549194137239552

I should mention that not only does the error above show up in the console log, but the whole scene locks up and the orbitcontrols no longer work.

by user 563549194137239552

Hi, will try to reproduce here now

Reproduced

Fixed :slightly_smiling_face: thanks for the report

OH FRICKING NIFTY!

by user 563549194137239552

I was wondering why text has a shadow as well

by user 563549194137239552

OK… fix confirmed in 2.60.4-pre

by user 563549194137239552