<?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[Betawave - Medium]]></title>
        <description><![CDATA[A blog on AR/VR, tech consulting, the cloud, and more - Medium]]></description>
        <link>https://medium.com/betawave?source=rss----8bbc06745c7c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Betawave - Medium</title>
            <link>https://medium.com/betawave?source=rss----8bbc06745c7c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:28:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/betawave" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Software Engineer’s Guide to Unity and AR/VR Development]]></title>
            <link>https://medium.com/betawave/a-software-engineers-guide-to-unity-and-ar-vr-development-part-2-5d2a696e3b8c?source=rss----8bbc06745c7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/5d2a696e3b8c</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Nicholas Hirsch]]></dc:creator>
            <pubDate>Thu, 15 Jun 2017 18:06:13 GMT</pubDate>
            <atom:updated>2017-08-30T17:12:50.344Z</atom:updated>
            <content:encoded><![CDATA[<h4>VR Development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*OC9h775Fn7ZMweLqea0npw.png" /></figure><p>In the <a href="https://blog.betawave.io/a-software-engineers-guide-to-unity-and-ar-vr-development-part-1-c20ce973bf8e">last post</a>, we gave you a quick overview of what software development in Unity looks like. There’s certainly a lot more we could cover about Unity, but in this post we’d like to speak to the shape of VR development.</p><p>There’s no code to follow along with in this article. We simply aim to give some context for what life is like as a VR developer.</p><h3>Developing for VR — An Overview</h3><p>VR development tends to be normal development plus the following 4 things.</p><p><strong>Firstly, there’s the VR tech stack.</strong> The tech stack, while perhaps not very mature as of 2014, became incredibly more mature by 2016. Reverend Kyle, host of the Rev VR Podcast went into this topic in a <a href="http://www.revvrstudios.com/knew-know-now">recent blog post</a>. We’re lucky that there’s a solid base of Unity plugins, stable SDKs, and platforms to target as of right now. For this post, we aim to describe the relevant pieces of tech to get going with the Rift, the Vive, and the GearVR.</p><p><strong>Secondly, there’s OOP &amp; interaction systems.</strong> Most VR environments and games in general are close enough to simulations that OOP is very applicable, so brush up! Moreover, because VR environments are so immersive, people tend to expect more from the virtual world around them. They expect objects in their environment to behave in whatever way their intuition tells them seems correct. In that sense, the increased immersion is really a double edged sword. You’ll need to think very carefully about your interaction models to make sure every emergent interaction between the user and the experience make sense, otherwise immersion can easily be broken.</p><p><strong>Thirdly (and probably most importantly), there’s performance.</strong> There’s clearly a lot of performance related coding as a result of VR having stringent requirements around the high FPS necessary for immersion. Excellent performance is also necessary because when it’s done wrong, you can induce <a href="https://en.wikipedia.org/wiki/Virtual_reality_sickness">VR sickness</a> which includes the following awful symptoms: <em>“general discomfort, headache, stomach awareness, nausea, vomiting, pallor, sweating, fatigue, drowsiness, disorientation, and apathy.”</em></p><p><strong>Finally, there’s a lot of work surrounding visuals and 3D work.</strong> This should really be no surprise. You may want to extend the game engine for your project’s particular needs. You might want to write custom shaders to employ a particular visual style or set of special effects. There is also a lot of work to be had working with both technical artists and pure artists to ensure their vision can be implemented. For those coming from a game development background, this should be no surprise. For those coming from a non-gaming background, there’s a lot to learn!</p><h3>VR Tech Stack</h3><h4>Enabling VR in Unity</h4><p>Unity actually makes enabling VR quite easy. Just open the <em>Player Settings</em> (Edit → Project Settings → Player) and check <em>Virtual Reality Supported</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*hP1AVTA8I51LFJj3aANBJg.png" /><figcaption>Standalone (PC/Mac/Linux) VR SDK Options</figcaption></figure><p>And voila! You’re now developing a VR app! We recommend taking a look at all the knobs and dials in <a href="https://docs.unity3d.com/Manual/VROverview.html">the Unity docs</a> at some point, but that’s basically it. It’s a <a href="https://docs.unrealengine.com/latest/INT/Engine/Editor/VR/ActivateVRMode/">similar story</a> in the Unreal Engine.</p><p>What about the camera? Don’t we need to do something to it? Great question! You can get VR working with a single camera, and the platform will figure out how to generate images for both eyes automagically. You can read more about the specifics of this brazen sorcery in the <a href="https://developer.oculus.com/documentation/unity/latest/concepts/unity-first-party-support/">Oculus docs</a>. Both Oculus and Steam provide a selection of more VR centric camera rigs, however. The camera rigs are typically the preferred way to go as they manage the controllers, can improve performance, and more. They are discussed further below.</p><p>You’ll also notice that there are different VR SDKs you can take a dependency on. Above you’ll see Oculus and OpenVR as options. In short, the Oculus SDK can be used by the Rift and the GearVR. The OpenVR SDK is primarily used by the Vive but aims to be an open platform and can be used by most headsets. For example, the Rift works with OpenVR. It should be noted that as of this writing the GearVR does not support OpenVR, however.</p><p>Aside: Sometimes OculusVR will be referred to as OVR, which is not the same as OpenVR.</p><p>To make things even more fun, there is also SteamVR. SteamVR is the runtime that the Steam VR client uses. SteamVR is built on top of OpenVR. SteamVR provides an extra layer of functionality beyond just being a simple VR SDK, and you can take advantage of this in your project via the <a href="https://www.assetstore.unity3d.com/en/#!/content/32647">SteamVR Unity plugin</a>.</p><h4>Enabling VR in Unity for Mobile</h4><p>Now let’s take a look at the settings for enabling VR for a mobile target. If you haven’t yet successfully built binaries for mobile, you’ll want to eventually look through the docs for <a href="https://docs.unity3d.com/Manual/android-GettingStarted.html">Android</a> and <a href="https://docs.unity3d.com/Manual/iphone-GettingStarted.html">iOS</a>. For now though, we’ll give you the gist of the VR specific stuff.</p><p>You’ll want to first switch platforms to target a particular mobile platform like iOS or Android. Open up your build settings (File → Build Settings) and look for the platforms section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*apcFHMCFSx7svI8-Q2mu5Q.png" /><figcaption>Available Platforms</figcaption></figure><p>Here is where you’ll want to select either iOS or Android and click <em>Switch Platform</em>. Then you’ll want to configure your build target in the player settings. Start by selecting one of the below icons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*J_y1PlE19leKiWnsm5F2dQ.png" /><figcaption>Left to right: Standalone, iOS, Android, WebGL</figcaption></figure><p>Then you’ll want to enable VR like in the previous section in the player settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*rO1joLKh_ia9t3SGRlMrew.png" /><figcaption>iOS VR SDK Options</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*tYrYiWr5zhhs8GSUHupJvw.png" /><figcaption>Android VR SDK Options</figcaption></figure><p>And that’s it!</p><p>Note that if you’ve never built binaries for your target platform before, we recommend you get a basic, non-VR Hello World app built and running on a device first. There are usually quirks in the setup for both iOS and Android, and it might save you some headache to tackle that setup separately.</p><h4>VR Camera Rigs</h4><p>The next thing you’ll probably want to do is get setup with a camera rig for your particular headset. Camera rigs are great as they typically support positional tracking for both the camera as well the controllers. Some also have additional functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*jhZB_TVvLQJM7lWEo2fCRg.png" /><figcaption>Oculus’ OVRCameraRig Prefab</figcaption></figure><p>The camera rig for the Rift and GearVR (a prefab called OVRCameraRig) is provided by the Oculus Utilities package (in the <a href="https://github.com/KatVHarris/GettingStarted_VR/tree/master/GearVR/Assets/OVR">OVR directory once unpacked</a>) and is available for download on the <a href="https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/">Oculus downloads page</a>. This camera rig supports the GearVR and touch controllers. It also has the ability to scale resolution as a function of performance to keep FPS smooth. This is done through settings on a component on the camera. You can read more about OVRCameraRig in <a href="https://developer.oculus.com/documentation/unity/latest/concepts/unity-utilities-overview/">the Oculus docs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*vy3svILh_duGRIksi28mNA.png" /><figcaption>The SteamVR [CameraRig] Prefab</figcaption></figure><p>The camera rig for SteamVR comes from the <a href="https://www.assetstore.unity3d.com/en/#!/content/32647">SteamVR plugin</a> and is available at <a href="https://github.com/ValveSoftware/steamvr_unity_plugin/tree/master/Assets/SteamVR/Prefabs">SteamVR\Prefabs\</a>[CameraRig].prefab once unpacked. The SteamVR camera rig doesn’t support auto-adjusting resolution based on perf by default, but that functionality does exist via additional packages like <a href="https://www.assetstore.unity3d.com/en/#!/content/63141">The Lab Renderer</a>.</p><p>Instructions to setup a camera rig are bundled with setting up VRTK, so without further ado…</p><h3>OOP and Interaction Systems</h3><h4>Interactions via VRTK</h4><p>As mentioned above, OOP and interaction systems are important in VR. Fortunately, Valve has released their <a href="https://vrtoolkit.readme.io/">Virtual Reality Toolkit</a> (VRTK) which provides a lot of basic functionality that we now come to expect in VR. It’s a great package that supports both the Oculus SDK and OpenVR. It provides goodies that help with the basics like teleportation, grabbing objects with touch controllers, basic inputs, interacting with 3D GUIs, and more! In it you’ll also find a very pluggable eventing system for when dealing with the nuances of interaction (touch, grab, drop, etc…).</p><p>We highly recommend getting setup and playing around with VRTK as a fun first project. <a href="https://vrtoolkit.readme.io/docs/getting-started">These instructions</a> will help you get setup with both a camera rig as well as VRTK. As of this writing, VRTK has <a href="https://github.com/thestonefox/VRTK/tree/master/Assets/VRTK/Examples">44 example scenes</a>. We recommend picking them apart and playing with the components therein. You can get an impressive amount done very quickly with this pretty basic functionality.</p><p>Aside from VRTK, we haven’t found any other packages quite nearly so useful.</p><h4>Creating your own Interaction System</h4><p>If VRTK doesn’t serve your particular needs, you can always create your own interaction system. As mentioned above, it can be a tall order in that you will want to make sure that any emergent behavior is also expected behavior to keep from breaking immersion.</p><p>So what’s a good way of thinking about interaction systems? In the web world, we have the Model-View-Controller (MVC) as a commonly referenced architectural paradigm. A similar breakdown of concerns/responsibilities that we like to use is Physics-AugmentedPhysics-GameLogic. Roughly put, Physics (P) and Augmented Physics (AP) combined handle reactions and simple interactions in the game world. The Game Logic (GL) layer handles any data or logic that isn’t physical in nature.</p><p>The P layer here is defined as whatever the physics engine can handle by default. The AP layer handles what the default physics engine can’t. Logic in the AP layer may arise from custom, additional physics specific to your experience. It might also arise from your experience needing more fine grained Newtonian physics that the physics engine doesn’t support by default. In the Unity world, AP modules typically live as Components on GameObjects that react to the environment around them and are typically not very stateful.</p><p>The GL layer is a departure from both P and AP as it encodes for logic that isn’t physical in nature. In a game of basketball, for example, points scored are not grounded in physics. It’s somewhat arbitrary that points are scored when the ball passes through the circumscribed plane of the basketball hoop. For that reason, we limit the logic that lives in a Component on the hoop to simply detecting that the event happened and then forwarding the event to the GL layer as soon as possible. This separation then allows us to deal with the GL in a purely abstract way, take advantage of pure OOP, and much more.</p><p>Using this model to separate concerns, you can then think through your desired interaction system and ask questions of it.</p><ul><li>Is interaction X more physical or more abstract in nature?</li><li>If physical, can interaction X be handled by the default physics engine?</li><li>Does a physical interaction X still need to be captured as an event some how?</li></ul><p>Asking these and other questions can help you decide where the logic powering your interaction system should live.</p><h3>Performance</h3><p>Without going into the nitty gritty of various optimizations, let’s take a high level look at VR performance by answering the following questions.</p><ul><li>What target do you want to hit?</li><li>How can you hit it?</li><li>What can you do when you’re not hitting it?</li></ul><h4>What performance target do you want to hit?</h4><p>Put simply, the goal is to <em>consistently</em> hit target frame rates to sustain immersion and prevent VR sickness. As little as a single dropped frame can result in VR sickness in some cases! You should target strictly greater than 90 FPS on desktop, and strictly greater than 60 FPS on mobile.</p><p>Why strictly greater than? Maintaining an average frame rate of 90 FPS or lower results in many frames being dropped to 45 FPS speeds when using the Rift or the Vive. On the GearVR, maintaining an average rate of 60 FPS or lower results in many frames being dropped to 30 FPS speeds.</p><p>Why does this happen? Firstly, a wandering frame rate is worse for immersion than a consistent yet lower frame rate. Snapping the frame rate therefore provides consistency. Secondly, assuming a consistent frame rate means we can leverage frame interpolation technologies like <a href="https://developer3.oculus.com/blog/asynchronous-timewarp-examined/">Asynchronous Timewarp</a>/<a href="https://developer.oculus.com/blog/asynchronous-spacewarp/">Asynchronous Spacewarp</a> (Oculus) and <a href="https://www.vrheads.com/what-asynchronous-reprojection-and-how-do-i-use-it">Interleaved/Asynchronous Reprojection</a> (Vive). The above links are definitely worth an in-depth read, but the TL;DR for Asynchronous Timewarp and its ilk is that it’s a technology that takes the latest frame, takes into consideration the movement of your headset since the latest frame, and fabricates a new placeholder frame when the current frame is taking too long to render.</p><p>This is an impressive technology that helps keep the VR experience running smoothly by safeguarding against the errant bad frames that can happen every so often. Safeguard is the keyword here. This is not something you should depend on to make your experience or game faster. This is something that was originally designed with the intent of smoothing over hiccups and making sure lower end PCs could run VR experiences smoothly and vomit free, so don’t abuse it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*gnud2fC-BOuIapJR2CPJBA.png" /><figcaption>Thrashing between 60 and 30 FPS on mobile</figcaption></figure><p>This is what it looks like when your performance is just on the border of either 60 FPS or 90 FPS. What you see here is that some frames are rendering faster than 16.666 ms and can support 60 FPS. Some frames, however, are rendering slower than 16.666 ms and Asynchronous Timewarp is kicking in and time is spent in vsync waiting for the next frame buffer swap.</p><p>You’ll also notice that in addition to all of the thrashing frames, 3 frames in this image took longer than 33ms. How do both of these things translate to the VR experience? The thrashing, timewarped frames would have been somewhat noticeable (<a href="https://developer3.oculus.com/blog/asynchronous-timewarp-examined/">search for “artifacts”</a>), but the &gt;33ms frames would have been very noticeable. They would have resulted in the entire experience stuttering for a moment.</p><h4>How can you hit these high frame rates?</h4><p>Simple! Spend time upfront designing with perf in mind.</p><p>Some good rules of thumb for designing for perf:</p><ul><li>Don’t put stuff in your app/game/experience if you don’t have to.</li><li>Understand your poly count/draw call count budget for a given scene.</li><li>Curate your assets properly.</li><li>Avoid spike inducing behavior like unnecessarily long calls in the main render loop.</li><li>Use resource pools to avoid getting penalized by expensive GC purges.</li><li>Pre-cache as much as you can.</li></ul><p>There are a lot of great tips and tricks out there. Since we can’t describe them all here, be on the lookout for them as you will probably need to employ each and every one at some point.</p><p>In the future, we plan to do a case study on mobile perf. If you’re curious right now though, you can keep reading about <a href="https://developer3.oculus.com/blog/squeezing-performance-out-of-your-unity-gear-vr-game/">Oculus’ recommendations for mobile perf</a>. Their post will give you a good sense for how to think about one of the most resource constrained VR platforms that exists, currently.</p><h4>What can you do when you’re not hitting your perf targets?</h4><p>Optimize! That and ensure you’re designs are still perf friendly. Assuming they are, there are many tools you can use to help debug performance so you know where to optimize first. We’ll spend time in a future post doing a deep dive to introduce these tools further. For now, have a look at them and simply know that they exist and are wicked sweet.</p><p><strong>Stats Overview</strong>: Incredibly useful to get a high level sense for performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*4276ZqTBokAVJ8VFUYXMKg.png" /><figcaption>Stats Overview</figcaption></figure><p><strong>Profiler (Hierarchy View)</strong>: A great way to understand what % of the frame was spent in which functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXsQfG1iOu9qw9X8KERPwQ.png" /><figcaption>Profiler + Hierarchy View</figcaption></figure><p><strong>Profiler (Timeline View)</strong>: A great way to visualize the ordering of the calls that went into rendering your frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYxS6ei7TegDMrBgAZbyiA.png" /><figcaption>Profiler + Timeline View</figcaption></figure><p><strong>Frame Debugger</strong>: Useful when trying to understand draw call counts, draw call batching, etc…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*Ms-7H-RuyqyMYGOkZNfJyQ.png" /><figcaption>Frame Debugger</figcaption></figure><h3>Visuals &amp; 3D</h3><p>For sake of completeness, we included visuals &amp; 3D as a category of things you’ll want to care about as a VR dev. There is substantial discussion to be had around this, however, so we’ve saved it for the entirety of an upcoming post. In said post, we’ll again go for breadth and talk about much of what Unity has to offer and give a developer’s take on it.</p><h3>That’s a Wrap!</h3><p>We hope this post has given you a better sense for some VR specific topics. The emphasis on perf and interaction systems shouldn’t be a surprise for those with a games background. The tech. stack and some of the perf considerations are unique to VR, however. Since we’ve barely scratched the surface, don’t be afraid to dive further into the specifics via the <a href="https://docs.unity3d.com/Manual/VROverview.html">Unity:VR</a> or <a href="https://developer.oculus.com/documentation/">Oculus</a> docs.</p><p><strong>Thanks for Reading! Until next time..</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d2a696e3b8c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/betawave/a-software-engineers-guide-to-unity-and-ar-vr-development-part-2-5d2a696e3b8c">A Software Engineer’s Guide to Unity and AR/VR Development</a> was originally published in <a href="https://medium.com/betawave">Betawave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Software Engineer’s Guide to Unity and AR/VR Development — Part 1]]></title>
            <link>https://medium.com/betawave/a-software-engineers-guide-to-unity-and-ar-vr-development-part-1-c20ce973bf8e?source=rss----8bbc06745c7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c20ce973bf8e</guid>
            <category><![CDATA[virtual-reality]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <dc:creator><![CDATA[Nicholas Hirsch]]></dc:creator>
            <pubDate>Thu, 11 May 2017 04:15:55 GMT</pubDate>
            <atom:updated>2017-06-15T18:11:00.088Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Software Engineer’s Guide to Unity and AR/VR Development — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VwQAJdXfus20YzNjLf_GcQ.png" /></figure><h3>Motivation</h3><p>So maybe you’ve heard that AR and VR are hot topics. Facebook’s F8 developer conference this year focused heavily on AR/VR. Tim Cook is on record as being a firm believer in AR, and rumors abound (as always) of Apple dropping a bomb this June at WWDC to support this stance. Microsoft has released the Windows 10 Creators Update whereby they’re basically giving OEMs the inside-out tracking of the Hololens for free. As such, Acer and Lenovo are expected to produce $300 AR/VR headsets by the end of year. Google has vowed to merge Tango into Daydream. A lot is happening in a short period of time by all of the major players.</p><p>Perhaps you’re thinking now would be a great time to pick up some Unity. We’d tend to agree! It’s very approachable, it <a href="https://unity3d.com/unity/multiplatform/vr-ar">has multi-platform support</a>, and it is the weapon of choice for most in the AR/VR space. That’s why we’ve put together this blog mini-series. That and we’ve found existing community tutorials and guides to be sparser than we’d like. As of this writing, the top google result for <a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=learning+unity+for+software+developers">“learning unity for software developers”</a> is an <a href="http://answers.unity3d.com/questions/254290/a-unity-tutorial-for-software-engineers.html">old Unity Answer</a> that just links to the Unity docs. So if you’re coming from traditional software development, stick with us and we’ll show you the ropes.</p><h3>First Post!</h3><p>The motivation for this blog series may be AR/VR, but we won’t touch any AR/VR SDKs until later in the series. This post in particular simply aims to familiarize the reader with Unity and a few common workflows.</p><p>Our goal is to give you a dev’s perspective on Unity. Unity’s tutorials will go deep and take you feature by feature. We want to go for breadth and show you what can be accomplished if you stay shallow but put a whole lot of things together quickly. (i.e. finding assets + simple components + coroutine timers + basic physics + directory structure + etc…) This way you can have an immediate sense for how everything fits together.</p><p>We’ll assume a healthy amount of technical competence, so we’ll assume you’ll have an easy time setting up environments and digging through docs when necessary. We also assume a minimum of 3D game terminology. We apologize in advance if we miss a step here or there though.</p><h3>Learning By Example</h3><p>To give you a sense for Unity development, we’ll take you through the building of a simple Unity app which hits on most of the key points you’ll need to know while building apps of your own.</p><p>This app will be a simple fireworks simulator.</p><h3>Getting Started</h3><p>If you don’t have it yet, you can download the latest version of Unity <a href="https://store.unity.com/download?ref=personal">here</a>. It is version <strong>5.6.0f3</strong> as of this writing. Once you’ve downloaded it, you’ll want to fire it up, create a new empty project, save the default empty scene as Assets\Scenes\scene.unity, and quickly get acquainted with the layout of Unity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*0sJD1ZY-AryR4ZvDZJtjSA.png" /></figure><p><strong>Project Window — </strong>A view of the Assets directory. This will contain 99% of your project files.</p><p><strong>Scene View</strong> — A rendering of your scene objects.</p><p><strong>Hierarchy Window</strong> — A hierarchical/compositional view of your scene objects.</p><p><strong>Inspector Window</strong> — The details pane for the highlighted object(s).</p><p><strong>Toolbar</strong> — Home to the translate/rotate/scale tools and preview/pause buttons.</p><p>These are all pretty straightforward windows. If you’d like to read more about them, you can find the docs <a href="https://docs.unity3d.com/Manual/LearningtheInterface.html">here</a>.</p><p>A typical workflow involves importing Unity Assets into the Assets directory, searching in the Project Window for objects you’d like to import into the scene, dragging said object into the Hierarchy Window to add it to the scene, choosing a tool from the Toolbar, manipulating said object in the Scene View with the chosen tool, and tweaking said object in the Inspector Window.</p><p>Now that we’ve created an empty project, the next question a developer invariably ask is: What is a good directory structure for our new project?</p><h3>Project Structures in Unity</h3><p>We recommend you quickly look at a handful of different open source Unity projects to get a sense for how projects are typically structured. One of our favorite open source AR apps for Unity is <a href="https://github.com/Microsoft/GalaxyExplorer">Microsoft’s Galaxy Explorer</a> for the Hololens. Also check out KatVHarris’s <a href="https://github.com/KatVHarris/GettingStarted_VR/tree/master/GearVR">GettingStarted_VR repo</a> for a boilerplate GearVR app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1H-ywc7H5NFKfcZWStN4eQ.png" /><figcaption><a href="https://github.com/KatVHarris">KatVHarris</a>/<a href="https://github.com/KatVHarris/GettingStarted_VR">GettingStarted_VR</a></figcaption></figure><p>You’ll notice very quickly that at the root of the Assets dir you’ll typically find the following directories: <em>Editor</em>, <em>Materials</em>, <em>Plugins</em>, <em>Resources</em>, <em>Scenes</em>, etc… Some of these are per the conventional layout. Some of these are <a href="https://docs.unity3d.com/Manual/SpecialFolders.html">Special Folders</a>. Special Folders are kind of like magic numbers. They sound really cool at first but ultimately have hidden gotchas that could make life great, or they could make life miserable for those caught unaware. The method <a href="https://docs.unity3d.com/ScriptReference/Resources.Load.html">Resources.Load</a>, for example, resolves paths by looking through all directories named Resources. This method also <a href="https://gist.github.com/nick-betawave/735e50bf74d8d777ae523297b8193be1">limits you</a> to loading from said directories or subdirectories only.</p><p>You’ll also notice that certain top level directories under the root Assets dir also contain these Special Folders as sub-directories. The <a href="https://github.com/KatVHarris/GettingStarted_VR/tree/master/GearVR/Assets/OVR">OVR</a> directory in the GearVR repo is one such example. If you see something like this you’re typically looking at an imported asset/dependency where the author of the package exported nearly their entire Unity project. Another thing to note is that Unity imports assets into the root <em>Assets</em> dir, so most projects end up with pretty messy top level dirs if left unattended. You might ask: can’t you just shove all of these dirs in a directory called <em>Dependencies</em>? Unfortunately, some asset authors take advantage of being able to park their files anywhere in your project. For example, some assets will happily place files in Assets\Shared Assets\, which is a special directory that has the advantage of running its scripts first. This is useful, but it can make dependency management a nightmare.</p><p>Finally, you’ll see that the Galaxy Explorer app doesn’t keep the majority of its textures, materials and prefabs in top level dirs like <em>Textures</em>, <em>Materials</em> or <em>Resources</em>. This is because the original authors opted for a predominantly component based directory structure where most files are organized by component (<a href="https://github.com/Microsoft/GalaxyExplorer/tree/master/Assets/GalacticCenter">GalacticCenter</a>, <a href="https://github.com/Microsoft/GalaxyExplorer/tree/master/Assets/SolarSystem">SolarSystem</a>, etc…). Another common strategy is to employ a functional directory structure where files are organized by function. Both styles can work. We’re personally big fans of the component based structure as project size increases (in our Unity code, React projects, and elsewhere), but you’ll often see the functional organization strategy out in the wild, especially in smaller projects like asset store dependencies.</p><p>Now that we know a bit more about directory organization, let’s import some assets!</p><h3>Acquiring Basic Assets</h3><p>If you’re working with an artist, great. They should be able to supply you with meshes, textures, materials, and all sorts of other goodies to load into your app. If you’re looking to get something running quickly for the sake of a prototype, you can also import something from the Unity Asset store, which integrates directly with Unity.</p><p>Finding pre-existing assets can range from being incredibly easy to tear-your-hair-out stressful. You can usually find something that functionally works, but it’s often very difficult to find a pre-made asset that fits into your app’s art style. Or you may simply not be able to find assets that meet even the most basic quality bar. A search on the Unity Asset Store for “city skyboxes” doesn’t turn up anything approaching photo-realism. A search for just “skyboxes” returns tons of photo-realistic, empty skies, however.</p><p>For our fireworks app, we’ll want something like this <a href="https://www.assetstore.unity3d.com/en/#!/content/39475">free audio pack</a>, this <a href="https://www.assetstore.unity3d.com/en/#!/content/67834">free particle effects pack</a>, and this <a href="https://www.assetstore.unity3d.com/en/#!/content/13001">free ground pack</a>. You can find these assets either on the website or through the assets tab in the same tab group as the Scene View of Unity. We find it easier to discover assets via the website, typically. Note, that the Unity asset store contains audio FX, sprite based animations, Unity specific files and more, in addition to generic mesh and texture files. You can find all sorts of great generic assets in the <a href="https://www.unrealengine.com/marketplace">Unreal Marketplace</a> and at <a href="https://www.turbosquid.com/">TurboSquid</a>, as well.</p><p>Also note that there are varied legal restrictions around some of these assets. You’re allowed to <a href="https://unity3d.com/legal/as_terms">share Unity assets</a> with your team. You’re allowed to use Unreal Marketplace assets in Unity, <a href="https://www.reddit.com/r/Unity3D/comments/3lnsp6/legal_question_using_ue4_assets_in_unity/cv7tnle/">excepting those free assets</a> released specifically by Epic. You can use <a href="https://www.turbosquid.com/3d-models/c4d-2016-audi-r8/945476">certain TurboSquid assets</a> <a href="https://blog.turbosquid.com/royalty-free-license/">royalty free</a>, though some assets are <a href="https://blog.turbosquid.com/royalty-free-license/#Editorial-Usage-tip">limited to editorial use</a> only. Be sure to read the fine print!</p><p>Now that you’ve found some assets through the website, click on <em>Add to Downloads</em> or <em>Add to Cart</em> and go through the purchase process if necessary. Then open Unity, ensure you’re logged into the same account you used to download or purchase assets, then click on the download manager icon. You can now <em>Download</em> and then <em>Import</em> all of the assets. This will bring each asset into your Assets directory, and you should see them listed in your Project Window. Great! Now you’re ready to put them to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*VtlEVwlIcbjFzng1XKfsAg.png" /><figcaption>Download Manager -&gt; Download -&gt; Import</figcaption></figure><h3>Setting the Stage</h3><p>The next thing we’ll want to do is to set the stage for our fireworks. We’ll create the ground by right clicking to create a plane in the Hierarchy Window. Congrats! You’ve just created your first GameObject. Name it HelloWorld so we can get that out of the way. Now click on the scale tool in the Toolbar. With the Plane selected in the Scene View, find the red/green/blue, 3-axis control and scale the plane up. By default Unity is configured to represent 1 meter as 1 unit. This is a good thing, don’t change this! Feel free, however, to tweak your plane to taste. You can exactly specify the scale of the plane via the Inspector Window.</p><p>When done tweaking your plane, you may want to add a simple texture to it to give it a more ground-like feeling. With the plane selected, go into the Inspector View and find the Renderer component. There should be a Materials array available to edit. Set the size property to at least 1, then click on the circle to the right of the text box associated with Element 0 (it should say None (…) or Default-Material) to bring up the asset selection pane. From this pane, search to your heart’s content for a texture that brings you joy as your new ground.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*8aai5kI1pn8a-0D2RuDopA.png" /><figcaption>Mesh Renderer component</figcaption></figure><h3>Coding in the Unity Universe</h3><p>By tweaking the materials array of the Renderer component, you’ve now configured yet another component on this GameObject, just like when modifying the scale of the object (thus modifying the transform component). <strong>Coding in the Unity universe consists of the creation and configuration of components, essentially.</strong></p><p>Components are small, compositional chunks of code, and an arbitrary number of them can be added to your GameObjects. The Renderer component mentioned above deals with the rendering of the object. You’ll find components that manage the physical properties of the object like mass and collision handling. You’ll also write C# code and derive from a class called MonoBehaviour to create your own custom components. Providing custom methods to handle lifecycle events, physics events, and more is the bread and butter of coding in Unity. Custom derived MonoBehaviours represent the vast majority of entry points into code in Unity.</p><p>Given that arbitrary components can be bolted onto GameObjects, sometimes at runtime even, GameObjects can be viewed like objects in Javascript. They are essentially a hash of assorted components. Instead of assuming an overall type for a given GameObject, just check that the component exists on the object when attempting to access and/or use it.</p><p>If you want to use a more script-like language, you also have the option of using the Unity sanctioned Boo (Python-esque) or UnityScript (Javascript-esque). C# does a great job and is robust and well supported, however. We’d recommend sticking with C#.</p><h3>Adding Our First Bit of Code to the App</h3><p>Let’s create a custom MonoBehaviour now that we know about components. This script will be used to create a behavior for fireworks!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c2d3fc2bd7064fb0d71b3f3f7dfa5ab/href">https://medium.com/media/9c2d3fc2bd7064fb0d71b3f3f7dfa5ab/href</a></iframe><p>Drop this in Assets\Scripts\Firework.cs and then switch back to Unity. You should notice a spinning icon in the bottom right of the entire application. This indicates that the app has picked up on your changes and is now compiling. If all went well, the icon should disappear and you shouldn’t see any errors in your console! You can find the console as a tab in the Project Window to verify this.</p><p>Now you can add this code as a component to anything in the Scene View/Hierarchy Window. Create a new 3D cylinder to represent your unique brand of fireworks and add it to the scene. Then use the search tool in the Project Window to search for Firework.cs. When you’ve located the file, drag and drop the file from the Project Window onto either the cylinder in the Scene View or the corresponding GameObject in the Hierarchy Window. Alternatively, you can click on your cylinder firework and then click on Add Component at the bottom of the Inspector Window and search for Firework.cs.</p><p>At this point, you’ve earned a quick play test given all your hard work. Hit play and see that.. your cylinder disappears? Check your console logs and you should see &quot;Kapow!&quot; and &quot;Destroyed&quot; are both printed to the screen. It looks like your Destroy() call is working! Fireworks do blow themselves up after all..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*be1N5giUR1Y3_2xez4c5fg.png" /><figcaption>Self-destructing fireworks!</figcaption></figure><h3>Packaging GameObjects into Prefabs</h3><p>This firework is the greatest thing since sliced bread! It’s absolutely amazing! Let’s package it up and sell it. We’ll corner the market. We’ll ship units from here to Timbuktu! We’ll…</p><p>Okay, so maybe you don’t share my excitement, but this firework is a big deal for your firework simulator. We’ll definitely want to reuse this particular configuration of GameObject and components. This is where prefabs come in. Once you’ve constructed an object hierarchy the way you like and configured it with components, you’ll want to capture this golden combination as a prefab. You can create a prefab from any GameObject by dragging the object from the Hierarchy Window into any directory in the Project Window. Go ahead and do this by dragging your object to Assets\Resources\ (create this directory if you need to) and giving it a name like Firework. Typically, prefabs end up in the Assets\Resources\ directory, though if you later organize your code by component, you’ll want to stick this prefab in the appropriate component dir.</p><p>So what’s so great about prefabs? How do these lend themselves to reuse? Prefabs are great as they can easily be instantiated wholesale at runtime. They are also a great source for modularity. While editing, all instances of a prefab in a scene are synchronized to the ground truth prefab in the Project Window. Changes to the ground truth prefab get reflected immediately in all instances of that prefab. You also have the ability to override individual properties of a prefab for individual instances in the scene. These overrides persist even when the underlying ground truth prefab changes. You can read more about the specifics of prefabs <a href="https://docs.unity3d.com/Manual/Prefabs.html">here</a>.</p><h3>Dealing with Physics</h3><p>Next let’s create a firework spawner that both spawns Firework prefabs and shoots them off into space. Add a 3D cube to the scene and place it on the ground somewhere. This will be the magic firework box. Now add the following script to your Assets\Scripts\ dir:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70b4d9313e4a28065abe69d462eeee24/href">https://medium.com/media/70b4d9313e4a28065abe69d462eeee24/href</a></iframe><p>Once Unity compiles this script, add this behavior as a component to the 3D cube you just added to the scene. Make note that the spawner is trying to programmatically access a Rigidbody component of the newly instantiated firework to set its velocity. We haven’t yet added this component to the Firework prefab. We’ll want to either edit the prefab directly or modify a Firework prefab that exists in the scene and remember to hit apply once we’ve made our changes. Go ahead and add a Rigidbody component to your amazing Firework prefab now.</p><p>Now click the run button to preview the app again. You’ll note that the firework first appears exactly 1 meter above the spawner. If you move the spawner around, the firework will still show up above it. We set the position of the instantiated object via the spawner’s position (this.transform.position) in world coordinate space. This is because the firework was instantiated without being attached to a parent and so needed a world coordinate position. We could have parented the firework to the spawner and the modified the localPosition of the firework to achieve the same effect.</p><p>Also note that the component has a publicfireworkStartVelocity and can be modified in the Inspector Window after adding the component to the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*pM91OkpU8Wc03AwtS-X_wg.png" /><figcaption>Public members are exposed in the inspector</figcaption></figure><h3>Debugging Your Cube Launcher</h3><p>At this point you should have a cube that shoots cylinders up into space. The cylinder should exist for a predetermined amount of time before disappearing into the aether, leaving behind only a debug trace of its existence. The cube should launch a cylinder every FIREWORK_GENERATION_PERIOD_IN_S seconds. Check to see that you’ve got roughly this.</p><p>So does it work? Yes? Great! No? Here are some things you can do to debug what’s happening.</p><ol><li><strong>Print via Debug.Log</strong> — printf debugging has been useful for a long time and will continue to be useful through the foreseeable future.</li><li><strong>Attach Visual Studio Debugger</strong> — If you really want to see your code in action, Unity has really great interop with VS. Open your source thru Unity by double clicking on a script file. Click on the run button in Unity to preview your game. Once VS is open, you should see a button to attach to Unity. Set some breakpoints and you’re off to the races!</li><li><strong>Have a Strong Mental Model</strong> — Having a very solid mental model of what’s happening in Unity is key to solving many if not most problems. So many things are handled under the covers by the physics engine, component lifecycle events, etc… We find that for simple apps, we write less code in Unity than when in other environments, and this only makes having a strong mental model that much more crucial. When there’s only 3 lines of code to debug, your debugger can’t help you as much as you’d think.</li></ol><h3>Adding Some Pizzazz</h3><p>To really round out this fireworks simulator, we’ll want to add the fireworks effects we downloaded and imported earlier. If you downloaded the free particle effects pack up top, you’re in luck! Like any good asset package, the authors of <em>Simple FX — Cartoon Particles</em> have included a demo scene that contains examples of their particle effects in action. You can find that scene at Assets\SimpleFX\_Demo\Demo.unity. Save your current scene, open Demo.unity, and take a look at the Hierarchy Window. You should see an object called FX_Fireworks_Blue_Large under the object FX.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q9ayKiHAjs7_5jcxcb65IA.png" /></figure><p>Copy this object, open the scene you’ve been working on, and paste into the Hierarchy Window. Rename the pasted object to ExplosionEffect. Now drag your Firework prefab from the Project Window into the Hierarchy Window. Drag ExplosionEffect and make it a child of your firework prefab instance. Update the transform of ExplosionEffect so its position is zeroed out, and uncheck the top-left most checkbox in the Inspector Window so the object is disabled by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*gPCqKkdx0dLPjkePwU7U3Q.png" /></figure><p>We will later enable this GameObject via code, which will allow us to trigger the explosion effect precisely when we want to because this particular particle system is configured to run on MonoBehaviour::Awake. Now update the prefab via clicking Apply on the instance of Firework, and remove said instance from the scene.</p><p>Finally, edit Firework.cs and add the following lines to the body of Explode():</p><pre>var explosionObj = this.transform.Find(&quot;ExplosionEffect&quot;).gameObject;</pre><pre>explosionObj.SetActive(true);</pre><p>And voila! Preview in Unity and you should see the particle effect activate after a few seconds when the fuse timer elapses and kicks off the call to Explode(). If the explosion isn’t in view, you’ll need to adjust the orientation of Main Camera if you haven’t already . Nice work!</p><p>Also note that you can access an object’s Transform from a GameObject and vice versa. We should also point out that the links that encode for the object hierarchy in the Hierarchy Window are stored on the Transform via <a href="https://docs.unity3d.com/ScriptReference/Transform-parent.html">Transform.parent</a>. This is why you call Find() on the Transform and not on the GameObject.</p><h3>Opportunities for Polish</h3><p>We’ll leave the addition of awesome sound effects as an exercise for the reader.</p><p>Things you might also want to do:</p><p><strong>Hide the firework cylinder on the call to Explode. </strong>Hint: You may be tempted to make use of SetActive(false), but that path only ends in tears. You’ll want to take a look at doing something with the MeshRenderer for the cylinder instead.</p><p><strong>Change the scene and setting so that it’s nighttime and not daytime. </strong>Hint: You’ll want to do something with the Directional Light and also change some settings on Main Camera.</p><p><strong>Make the firework explode only when it has stopped vertical motion. </strong>Hint: Either calculate the fuse time as a function of initial velocity, or periodically check for negative velocity along the Y axis (i.e. the firework has started its journey back to Earth) in an override of MonoBehaviour::<a href="https://unity3d.com/learn/tutorials/topics/scripting/update-and-fixedupdate">FixedUpdate</a>.</p><p><strong>Spice up the 3D models used for your firework launcher as well as the fireworks.</strong></p><p>There is always opportunity for polish, so have fun!</p><h3>Success!</h3><p>We hope you’ve enjoyed this first dive into Unity. It most certainly goes much deeper, as evidenced by the fact that <a href="https://unity3d.com/unity/roadmap">Unity still has a substantial roadmap</a>. For now though you should have all the tools necessary to start tinkering or even start working on your own cool ideas.</p><h3>For Next Time…</h3><p>The next few posts in this mini-series will try to shed light on how to incorporate Unity with the traditional Software Development Lifecycle. We will also speak to the breadth of what Unity can do so that developers can get a sense for what is possible. We will also introduce mental models that we find useful when working in a games environment. Finally, we’d like to dip our toes into some VR!</p><p>You can continue reading the next post <a href="https://blog.betawave.io/a-software-engineers-guide-to-unity-and-ar-vr-development-part-2-5d2a696e3b8c">here</a>.</p><p><strong>Thanks for reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c20ce973bf8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/betawave/a-software-engineers-guide-to-unity-and-ar-vr-development-part-1-c20ce973bf8e">A Software Engineer’s Guide to Unity and AR/VR Development — Part 1</a> was originally published in <a href="https://medium.com/betawave">Betawave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>