You can view performance statistics, like framerate and memory usage, by pairing your device to Lens Studio. For more information, see Pairing to Snapchat.
Logging in Lens Studio
To print a message to the
Logger panel, use the
print() command from any script:
Logger panel should be visible by default at the bottom of the screen. If it's not, you can add a new
Logger panel through the top menu button:
Window -> Panels -> Logger.
You can clear the Logger's history by right clicking in the panel and selecting
Clear. To copy the text of a log message to your clipboard, right click on the message and select
Logging on Device
You can use the TextLogger package to view log messages on device. Add TextLogger to your project by following these steps.
- Download the TextLogger package
- Open your project in Lens Studio
Right click inside the
Objectspanel and select
In the file select window that appears, choose the
TextLogger_Importable.lsofile downloaded in Step 1.
You should see the TextLogger object appear in your
You are now ready to use TextLogger!
Before trying any of the following, make sure you've already imported TextLogger as described above!
You may not be able to use TextLogger in script during the
InitializeEvent, since TextLogger initializes itself during this time. To be safe, avoid using it until after the
InitializeEvent has finished. See the Script Events guide for more information on events.
Adding Log Entries
From any script, call
global.logToScreen() to show a message on the screen.
global.logToScreen("hello!") global.logToScreen("these are custom logs...") global.logToScreen("just import the TextLogger object and call:") global.logToScreen("global.logToScreen('text')");
For convenience, TextLogger automatically calls
print() on every log message. You can disable this by adding a
true argument to the
// Adding 'true' disables the automatic print() call global.logToScreen("This appears on screen but not in the Logger", true);
You can change settings by selecting the TextLogger object and making changes in the
Disabling this will stop log messages from appearing on screen. This makes it easy to switch between development and production, since you'll probably want to disable logging before submitting a finished Lens. You can also set this in script:
// Disable logs appearing on screen global.textLogger.setLoggingEnabled(false);
Text Color controls the color of all text logs displayed. It's also changeable in script:
// Change text color to red global.textLogger.setTextColor(new vec4(1,0,0,1));
LogLimit specifies how many log messages TextLogger allows on screen at a time (4 by default). If this limit is exceeded, previous log entries will start being removed. There's also a script interface:
// Only one log entry will be shown at a time global.textLogger.setLogLimit(1); // Clear all existing log entries global.textLogger.clear();
It's probably better not to touch this, but if you want to use a different material for your text you can set it here.
This specifies which camera TextLogger will use for positioning text. It's usually fine to leave this blank, since as a fallback TextLogger will automatically find a camera in the scene hierarchy.
Still Looking for help?Visit Support