<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fathom on Medium]]></title>
        <description><![CDATA[Stories by Fathom on Medium]]></description>
        <link>https://medium.com/@FathomCompany?source=rss-ab000ba0223e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YBjVLiwHnCom6T0V.jpg</url>
            <title>Stories by Fathom on Medium</title>
            <link>https://medium.com/@FathomCompany?source=rss-ab000ba0223e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:34:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@FathomCompany/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Snapchat Lens Studio for Unity Developers]]></title>
            <link>https://medium.com/@FathomCompany/snapchat-lens-studio-for-unity-developers-a70ae4de0f45?source=rss-ab000ba0223e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a70ae4de0f45</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[snapchat]]></category>
            <dc:creator><![CDATA[Fathom]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 15:05:54 GMT</pubDate>
            <atom:updated>2019-03-15T15:05:54.971Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyKfPyZn6HBE3d9qzDzdvQ.jpeg" /></figure><p><em>TL;DR — Snapchat Lens Studio is a powerful and expressive AR tool which happens to have a lot in common with Unity. For developers who spend much of their time in Unity, this article offers a quick overview of how the two programs are similar and different, including examples of congruencies between the two, so you can dive right in with a comfortable baseline.</em></p><p>Our team at <a href="https://www.fathom.company/">Fathom</a> has been asked about developing Snapchat lenses several times since the tool for creating them, <a href="https://lensstudio.snapchat.com/">Snapchat Lens Studio</a>, went public in early 2018. To be honest, we had initially discounted the software as a sort of plaything, but once we started digging in, we found the tool to be super robust and that it offers an exciting opportunity to quickly build immersive, AR micro interactions. I would wager, too, that the component-based architecture and overall UI of Lens Studio was heavily inspired by <a href="https://unity3d.com/">Unity</a>, hence this article!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bajGyApHZluqtOQD60vPZw.png" /></figure><p>We’ve come to see Lens Studio as a platform for “interactive haikus,” tiny AR worlds that can be an experiment in AR interactivity, an engaging branded experience, or a purely creative exploration using face-based inputs. These experiences can be <a href="https://lensstudio.snapchat.com/guides/submission/submitting-your-lens/">published within minutes</a> and shared to world using a generated <a href="https://lensstudio.snapchat.com/guides/sharing/snapcodes/">Snapcode</a>.</p><p>You can start building Snapchat lenses immediately by <a href="https://lensstudio.snapchat.com/download/">downloading the application here</a>.</p><p>And just by chance, it was recently reported that Snapchat will be <a href="https://cheddar.com/media/snapchat-to-launch-gaming-platform">announcing its own gaming platform</a> in April, 2019. What better way for Unity game developers to explore this new ecosystem than through the existing Lens Studio tools?</p><p>Before we dive into the two programs’ similarities, here’s how Lens Studio projects are different than Unity ones:</p><ul><li><strong>Small project size:</strong> packaged lenses <a href="https://lensstudio.snapchat.com/guides/submission/submission-guidelines/">must be under 4 MB</a></li><li><strong>Untyped JavaScript:</strong> vanilla JS, no C# with typing</li><li><strong>Limited inputs:</strong> touch and gesture input, face-based input, AR surface and image marker tracking, so no gamepads, keyboards, mice, etc</li><li><strong>No compilation:</strong> all scripting here, which keeps the editor workflow quick and seamless</li><li><strong>Publishing:</strong> lenses can only live on Snapchat’s mobile platform, no external build files can be shared</li><li><strong>Ad-hoc distribution:</strong> published lenses get a Snapcode which is the gateway to your custom lens experience</li><li><strong>No built-in physics:</strong> plenty of linear algebra classes, but you’ll have to code your physics and collision system, or fake it</li><li><strong>Limited community codebase:</strong> lots of <a href="https://www.reddit.com/r/SnapLenses/">examples of working lenses</a>, but really not much code sharing in the community. <a href="https://lensstudio.snapchat.com/templates/">Snapchat’s templates</a> are the best existing resource that we’ve found so far. There’s no equivalent to Unity’s Asset Store for bringing external resources into your project</li></ul><h3>Built-in Features</h3><ul><li>Face detection and mapping—2D/3D anchoring with simple head occlusion</li><li>Face gesture events—mouth open/close, brows raised/lowered, kiss, smile</li><li>Face manipulation — distort/liquefy, slice, duplicate/composite, image effects (teeth whitening, tone mapping, eye color change)</li><li>2D/3D assets — mesh, text, gifs/images as billboards, rigged animation</li><li>Environment tracking — image markers, Snapcode markers, 3D surface tracking</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KBR3eLPMTcBbrp_Y_7-iQ.png" /></figure><h3>Interface</h3><p>So much of the UI between Unity and Lens Studio is equivalent, we’ll just show side-by-side images of the main panels and note how they differ.</p><p><strong>Hierarchy = Objects</strong><br>The main scene tree is displayed in the Objects panel. In Lens Studio, there is no concept of multipleScenes like there is in Unity. The entire project exists in a single global object of type <a href="https://lensstudio.snapchat.com/api/classes/ScriptScene/">ScriptScene</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzvQ5mQpgmOXWfTIyiJCWg.jpeg" /><figcaption>Unity Hierarchy panel and Lens Studio Objects panel</figcaption></figure><p><strong>Project (Assets) = Resources</strong> <br>All imported resources for the project are managed in the Resources panel. These are mapped to the {Project Path}/Public folder in the same way a Unity project’s Assets folder is mirror of the file structure. You can drag external files onto this panel to add them to the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79NTjfU6kWX_2yz9hijqZA.jpeg" /><figcaption>Unity Project panel and Lens Studio Resources panel</figcaption></figure><p><strong>Scene = Scene</strong><br>The main editor space for both programs is the Scene view. The same transform tool shortcuts in Unity along the QWERTY keys also work in Lens Studio. The main difference is 2D Scene View in Lens Studio, which will show a contextual 2D view, depending on which SceneObject is selected. For instance, a selected FaceMask object will display the 2D face binding anchors when View 2D Scene is selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SkfgVT80PHW6RMwl-sqnfg.jpeg" /><figcaption>Unity and Lens Studio Scene views</figcaption></figure><p><strong>Game = Preview</strong><br>You can preview your live lens at all times in the Previewpanel. Unlike Unity, there is no Play or Pause here. The lens is running constantly and will restart when it detects scripting or scene changes. You can force restart the lens by clicking the circular arrow to Reset Preview. You can view the lens through your webcam by clicking the small icon. Lastly, you can stream the lens right to your phone once you’ve <a href="https://lensstudio.snapchat.com/guides/general/pairing-to-snapchat/">paired Lens Studio to your device</a>. This is super useful for AR-tracked lens interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y11gMjJ2_9bW-Hqxxd0gbg.jpeg" /><figcaption>Unity Game panel and Lens Studio Preview panel</figcaption></figure><p><strong>Inspector = Inspector</strong><br>When a SceneObject is selected in the Objects panel, the Inspector will show the settings and components attached to that object. Look how similar!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IPZkmGbHyc-ysRqCdMPNOg.jpeg" /><figcaption>Unity Inspector and Lens Studio Inspector</figcaption></figure><p><strong>Console = Logger</strong><br>Get feedback from your scripts in the Logger panel. Instead of Debug.Log(&quot;You say Console&quot;); a la Unity, you can use the global function print(&quot;I say Logger&quot;);.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ttdm2_9YTOsp_NHFqGoPLA.jpeg" /><figcaption>Unity Console and Lens Studio Logger</figcaption></figure><h3>GameObject, meet SceneObject</h3><p>Unity’s generic element in a scene is the GameObject and the equivalent in Lens Studio is the <a href="https://lensstudio.snapchat.com/api/classes/SceneObject/">SceneObject</a>. Every SceneObject has a <a href="https://lensstudio.snapchat.com/api/classes/Transform/">Transform</a> that defines its orientation in 3D space. They are arranged in a parent-child hierarchy, so empty SceneObjects can be used as folders that contain multiple children.</p><p>There is also a <a href="https://lensstudio.snapchat.com/guides/general/prefabs/">Prefab</a> system similar to Unity’s. Any SceneObject can be dragged into the Resource panel to create a prefab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*tIGaR7ZHVc4nrNe20qtanA.gif" /><figcaption>Creating a Prefab in Lens Studio</figcaption></figure><p>The big difference here is that a prefab is configured on the instance, not on the prefab asset in the Resources panel. That is to say, you first instantiate a prefab by dragging it into the Objects hierarchy, make some changes, and then hit the Apply button. This will push changes to all other instantiated prefabs of this type, and all future instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*qY-pw_WCEmMjTksCIj4bqQ.png" /><figcaption>Hit the Apply button to commit prefab changes</figcaption></figure><h3>MonoBehaviour, meet Component</h3><p>One of Unity’s best features is its component-based architecture. As you may have noticed in the Inspector panel comparison above, Lens Studio uses an almost identical system. You can attach any number of Components to a given SceneObject to define its behavior.</p><p>All Unity components derive from the class MonoBehaviour and all Lens Studio components derive from the class <a href="https://lensstudio.snapchat.com/api/classes/Component/">Component</a>. Every component you can attach to a SceneObject and every script you create will automatically derive from this class.</p><p>There are a number of built-in components that can be used to create custom behavior. Hit the + Add Component button in the Inspector panel to view them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*T78qIMVF0Gk2MDulsW8uCg.gif" /><figcaption>Adding a built-in component to a SceneObject</figcaption></figure><h3>Enough About the UI, Let’s See the Code!</h3><p>Ok, ok. We’ve seen how similar Unity and Lens Studio are from an interface perspective. Let’s get into the code!</p><p><strong>Attaching a script to a SceneObject</strong><br>Like Unity, all custom logic is created in instances of <a href="https://lensstudio.snapchat.com/api/classes/ScriptComponent/">ScriptComponent</a>. First create a Script resource in the Resources panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*zYSU0sVJXLO8ZxbotiQiuQ.gif" /></figure><p>After creating and naming your Script resource, you can now attach the script to any SceneObject from the Inspector panel. A ScriptComponent can hold any number of script resources, whose logic will be triggered by a corresponding ScriptEvent. For scripts that don’t have any state, you can simply choose the relevant event and the code will run accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*CcTy2y5ywLe3dDYUelXs8Q.png" /></figure><p>If you’re like me, and want a more Unity-like scripting experience, you can run a single script from the Initialized event and bind callbacks to any other event that occurs in the scene. Here’s an example of that syntax.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bdd18c7b9c29de1e00499524b7ca0a6/href">https://medium.com/media/2bdd18c7b9c29de1e00499524b7ca0a6/href</a></iframe><p>Events are bound using their Event class names as a string. You can find all <a href="https://lensstudio.snapchat.com/api/Events/">available events here</a>.</p><p>If you want to include state in your script (which exists per instance of the script in the scene) use variables at the top of the script scope and run the script during the Initialized script event at the component level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*j6qZN7PMUsOm1PpUGykvFg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb33ac9cb6d9b99dfdfc59881d810a5b/href">https://medium.com/media/fb33ac9cb6d9b99dfdfc59881d810a5b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3S6XqT3tHjS4I7AN1uHw8w.png" /></figure><p>Now you’re probably thinking about all the weird micro games you can make using eyebrow detection as the input! I know I am…</p><p><strong>Creating script properties in the Inspector</strong><br>In Unity, public properties are exposed to the Inspector at the component level. Of course, Lens Studio has an equivalent feature, though the syntax looks different. You can provide many types of <a href="https://lensstudio.snapchat.com/api/InputTypes/">Input field</a> data and references to other SceneObjects and Components using the following code:</p><pre>// The @input symbol after comment slashes indicates an Input field<br>//@input int myScore<br>//@input vec3 myColor {&quot;widget&quot;:&quot;color&quot;}<br>//@input SceneObject someObjectReference<br>//@input Component.ScriptComponent someOtherScript<br>//@input Component.MeshVisual someOtherMesh</pre><pre>// Access all of these properties from the `script` object <br>print(script.myScore);</pre><p>Notice how specific Component types use the Component. prefix to expose them to the Inspector. Without this prefix, the script will throw an error.</p><p>In some cases, you’ll want a better UI for the type of data you’re exposing to the Inspector. Unity does a great job choosing the right input UI for the data type. With Len Studio, you’ll have to be a bit more explicit. See the myColor widget line above and find more examples of <a href="https://lensstudio.snapchat.com/guides/scripting/custom-script-ui/">Custom Input UI here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*C9WunTO1gBuLVTLvaSDNEw.png" /><figcaption>Now, all of our properties are available in the Inspector</figcaption></figure><h3>Making Things Happen</h3><p><strong>Grabbing SceneObject and Component references</strong><br>Everything starts with the script variable, which is a reference to the current script instance, like this in Unity context. Once you have a reference to the SceneObject, you can start grabbing components and manipulating their values. Here’s how to grab those references in the code:</p><pre>// Get a reference to this SceneObject<br>// Equivalent to `gameObject` in Unity<br>var so = script.getSceneObject();</pre><pre>// Get a reference to this SceneObject&#39;s Transform<br>// Equivalent to `transform` in Unity<br>var t = so.getTransform();</pre><pre>// Equivalent to `gameObject.GetComponent&lt;T&gt;()` in Unity<br>var meshViz = so.getComponentByIndex(&quot;MeshVisual&quot;, 0);</pre><p>Find more methods available to the SceneObject, like adding or removing components at runtime <a href="https://lensstudio.snapchat.com/api/classes/SceneObject/">here</a>.</p><p><strong>Communicating between scripts</strong><br>When writing a script, you can expose “public” properties and methods via the script.api object.</p><pre>// Script 1</pre><pre>// Prints a message<br>script.api.showWelcomeMessage = function(<em>msg</em>) {<br>  print(msg);<br>}<br></pre><pre>// Script 2</pre><pre>// Set the reference to the other object in the Inspector<br>//@input Component.ScriptObject welcomeScript</pre><pre>// Check for the Script1 reference and that the <br>// method we want to use exists<br>if(<br>  script.welcomeScript &amp;&amp; <br>  script.welcomeScript.api.showWelcomeMessage<br>){<br>  // Send a welcome message using our reference to Script 1<br>  script.welcomeScript.api.showWelcomeMessage(&quot;Hi there!&quot;);<br>}</pre><p>Lastly, the global namespace is available for static access to properties and methods. Values set here are available to all of your, as long as they are defined before you try to access them:</p><pre>global.myMessage = &quot;Hello, World!&quot;;<br>global.sayHello = function(message)<br>{<br>    global.myMessage = message;<br>    print(global.myMessage);<br>}</pre><h3>Next steps</h3><p>By now, it’s probably clear how similar Unity is to Lens Studio, which is great for Unity creators who want to start experimenting with sharable AR lenses. There’s plenty more to learn, like <a href="https://lensstudio.snapchat.com/guides/scripting/playing-3d-animation/">triggering 3D animation</a>, <a href="https://lensstudio.snapchat.com/guides/scripting/touch-input/">handling touch input</a>, and <a href="https://lensstudio.snapchat.com/guides/sharing/sharing-your-lens/">sharing your creations</a>.</p><p>If you’ve experimented with Lens Studio, share your lenses in the comments. Or if you are Unity user who jumped into lens development, let us know what you think of the tool!</p><p><em>Eric Howard is Chief Technologist and Co-founder of Fathom, a digital creative studio that brings brand experiences to life through storytelling and interaction. </em><a href="https://fathom.company/"><em>www.fathom.company</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a70ae4de0f45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>