Javascript communication sample

Hello! Looking to modify the myscript.js file but cannot seem to find it in the sample project. Can someone guide me to it? Thanks in advance!

Original Post on Discord

by user 236905740416057345

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Hi Snax! To modify your myscript.js file or add a new script, you can either:

  1. Add a file with a .ts or .js extension directly inside the src/scripts/ directory of your generated project, for example src/scripts/myscript.js.
  2. For Unity specific setups, organize your code into NPM Definition Files (npm packages) for modularization and local installation. In Unity, you can create these via Create > NPM Definition then add TypeScript files by right-clicking an NpmDef file and selecting Create > TypeScript.

For more details, you can refer to the section on “Creating a new component” in the documentation (see the documentation).

1 messages left GPT 4
thread_IPSenqpb3ZEnM9xVMQH6Jsm4
Thanks for your feedback!

Hey @Snax , if you open the Workspace by clicking the “Workspace” button you can find all scripts used in the web project:

In this sample some of the code is in an NpmDef (demonstrating how to set up code that lives in your 3D scene) and some code is right in the index.html (demonstrating accessing the 3D scene and Needle from “outside”).