Debugging in the Browser's Console Window - Accessing a GameObject/Object3D from the command line

To debug while the game/simulation is playing, I like to work from the command line. I know that by logging a variable to the console log in my TypeScript script, I can view its contents. How can I reference the variable’s gameObject’s or Object3D 's properties and methods to change its position, rotation, scale or send method calls to it from the command line?

Or, similarly how I debug in Unity, how do I run the Find method/function from the browser console command line?

Original Post on Discord

by user 581381221087445033

Interesting request.
You may like what @marcel :cactus: has been working on in terms of live syncing between Unity Editor and a running Needle instance

Regarding how to use needle engine methods in the console:

That being said, you can use the command line too:

  • type const scene = Needle.Context.Current.scene to get the scene
  • scene.getObjectByName('someName') gets a specific object (keep in mind three may rename objects if they have duplicate names in Unity)
  • on that, you can then call methods as usual
  • you can also get specific components with const someComponent = scene.getComponentInChildren(Needle.WebXR)
  • or const someComponent = Needle.GameObject.findObjectOfType(Needle.WebXR)

You’re also getting suggestions for what’s available

I saw the synced scene view camera demo video on Twitter and was excited about that. I wasn’t sure if that was pushed out to GitHub main branch yet. :blobaww:

by user 581381221087445033

Not yet but I believe Marcel wants to release it Soon ™ :slightly_smiling_face:

Yes, hopefully this week

A first version to get some feedback :slightly_smiling_face:

I’m happy to wait for it. Well Worth the Wait™️ :coolcat:

by user 581381221087445033

I’m hoping to roll the above instructions into my own set of documentation to describe my workflow from start to deploy, and hope to then turn that into an instructional video as well.

by user 581381221087445033

Then share it with you in case you wanted to use any of it.

by user 581381221087445033

That would be awesome! Thanks