How to change 'ObjectToExport' on USDZ Exporter in runtime?

I have created a custom component and changing “object to export” on click of a button. When I print the name of the object in console, it shows the right output. But my build always keeps spawning the default object in QuickLook.

        {
            this.exporter.objectToExport = this.currentObject?this.currentObject[this.currentIndex] : this.exporter?.objectToExport;
            console.log(this.exporter.objectToExport?.name);
        }

What am I missing here?

Original Post on Discord

by user 373346625025736705

Changed it with the following code, but now it crashes when I try to change the exported object on iPhone 14 Pro.

@serializable(Object3D)
    exporter?:Object3D;

...



if(this.exporter)
        {
            var usdExport = GameObject.getComponent(this.exporter,USDZExporter);
            if(usdExport)
            {
                usdExport.objectToExport = this.currentObject?this.currentObject[this.currentIndex] : usdExport.objectToExport;
            }
            //console.log(this.exporter.objectToExport?.name);
        }

by user 373346625025736705

currentObject is an array here?

You can use
GameObject.getComponent(this.gameObject, USDZExporter); instead

A crash would typically mean the device goes out of memory (e.g. too many/too large textures or meshes at the same time)

Will try that. Is there a way to debug things when the app is running on phone browser

by user 373346625025736705

Yep, append ?console to the URL to get a handy console UI.

Or if you have a Mac, debug iOS/iPadOS from Safari while the phone is plugged in. Same with Android<>Chrome

?console is super fast and right on device, the full browser debuggers are useful for detailed timing and memory analysis and these kinds of things

Understood, thanks. Seems like I have a texture on one of the objects that’s causing the problem. May be memory issue. I will further look into it.

by user 373346625025736705