Skip to main content
Version: 5.x

Script Editor

Lens Studio provides a scripting editor to help you quickly write scripts to add interactive experiences to your Lenses. The script editor makes it easy to write Javascript for your Lenses by providing code completions, access to the API documentation, context understanding for writing and debugging, and more!

For TypeScript users, we recommend using an external editor as we currently do not support auto completion in the internal script editor. To allow your scripts to open by default in the external editor, go to the Preferences window and set your default editor.

Using the Script Editor

To open the Script Editor, double click a script in the Asset Browser panel.

Features

As you write your script, the Script Editor will provide you with suggestions for code that you might be trying to write, including suggestions for Lens Studio specific code.

For example, if you wanted to access an object that is in your scene within your script, as you declare the input, the Script Editor will suggest the type of things you can access.

When you complete the input declaration, Lens Studio will process what you write and summarize your inputs in the Inspector panel.

This tight coupling between the Script Editor and other Lens Studio panels allows you to quickly build interactivity into your Lenses.

You can also open multiple scripts in the Script Editor at the same time. When you have multiple scripts open in the Script editor, you will see a tab for each file. You can navigate to a tab by double-clicking the file in the Asset Browser panel, or by selecting the tab itself.

The Script Editor will mark unsaved file with a dot in the top right corner of the file’s tab. With the Script Editor panel in focus (e.g. while typing), CMD + S on Mac or CTRL + S on Windows will save the script, rather than the project itself.

External Editors

Scripts can also be edited using any text editor of your choice.

To open your script in an external editor, right click on your script in the Asset Browser panel and select Open in External Editor

Setting your Default Editor

You can open the Lens Studio Preferences to select how your scripts open by default. In your Lens Studio menu, press Lens Studio > Preferences > Editors. Then, in the pop-up window, check the box next to JavaScript or TypeScript.

Was this page helpful?
Yes
No

AI-Powered Search