<?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 No Such Dev on Medium]]></title>
        <description><![CDATA[Stories by No Such Dev on Medium]]></description>
        <link>https://medium.com/@nosuchstudio?source=rss-f77c2f8234a9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*R7vUGcVQNVlI9H40s5Mg2A.png</url>
            <title>Stories by No Such Dev on Medium</title>
            <link>https://medium.com/@nosuchstudio?source=rss-f77c2f8234a9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:10:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nosuchstudio/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[Want to Use Unity Ads in Your Game? Think Again…]]></title>
            <link>https://nosuchstudio.medium.com/want-to-use-unity-ads-in-your-game-think-again-769ce62aaccb?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/769ce62aaccb</guid>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[fraud]]></category>
            <category><![CDATA[ads]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Wed, 04 May 2022 23:53:09 GMT</pubDate>
            <atom:updated>2022-05-04T23:53:09.884Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6xd_f5VMEZMiK0RgcOUT4Q.png" /></figure><p>In this post I share my experience with Unity Ads in an online mobile game I made in 2019. This was my first successful game, reaching 1000 daily active users (DAUs). It was at this point that I decided to make money from my game. Since I was making the game in Unity, Unity Ads was the natural choice.</p><p>During the initial development and as I incrementally released new versions, the SDK was changing a lot. A bad sign that the APIs weren’t that stable… but hey, Unity was starting out on its online services stack and going through growth pains as a company.</p><p>From a technical standpoint Unity Ads SDK worked just fine. At times it had its quirks but for the most part the implementation was straightforward. Today in 2022 I bet the SDK is more stable and reliable.</p><p>But the thing that caught me off guard was Unity’s fraud team! They too, similar to their engineering team are new and figuring out the online space. They did weird things on my account which hindered my confidence in them. In a long holiday I made $20 in a day from Unity ads. A few days later the money vanished from my account. There was no communication of any kind from Unity. It wasn’t the end of the world but worse was yet to come.</p><p>In mid 2020, Unity blocked my org with a template message saying I was in violation of Unity’s terms and services. In theory they block you if you try to cheat by clicking your own ads or have fake users or bots click the ads. I wasn’t doing any of those. I was lucky enough that it was a known widespread bug in the fraud detection system and so Unity unblocked my org and low key apologized on the forums. Here is the forum post where I voiced my concerns over Unity’s fraud team’s activities:</p><p><a href="https://forum.unity.com/threads/my-org-got-blocked-with-no-explanation-why-the-way-unity-treats-us-developers-is-unacceptable.952392/#post-8042168">https://forum.unity.com/threads/my-org-got-blocked-with-no-explanation-why-the-way-unity-treats-us-developers-is-unacceptable.952392/#post-8042168</a></p><p>In early 2021, Unity blocked my org again. Telling me the same thing, that I was in violation of their terms of service. I tried opening multiple tickets but this time they kept sending me the same useless template message. I don’t think anyone from the actual fraud team viewed my ticket. I asked them politely to provide the evidence they have of my violations but I kept receiving the same template message. My forum posts on the matter also go on unanswered. Below is the link to my more recent forum post on the matter.</p><p><a href="https://forum.unity.com/threads/never-using-unity-ads-again-my-org-got-blocked-for-fraud-with-no-explanation-from-unity-in-months.1266593/">https://forum.unity.com/threads/never-using-unity-ads-again-my-org-got-blocked-for-fraud-with-no-explanation-from-unity-in-months.1266593/</a></p><p>I understand that fraud detection is critical and a hard problem to tackle and there is bound to be mistakes, but to not communicate a thing with your loyal developers and treat them like frauds is unacceptable. I have at this point given up on Unity Ads and the rest of Unity online services.</p><p>I looked around the Unity forums and the internet and it seems to be a repeated pattern for Unity’s fraud team to not communicate anything back to the developers. As such I don’t recommend using it.</p><p>Here are a few more examples of indie developers being abandoned, mistreated and screwed over by Unity:</p><p><a href="https://forum.unity.com/threads/unity-ads-stopped-serving-ads-all-of-a-sudden-fill-rate-dropped-to-0.1255575/#post-8048303">https://forum.unity.com/threads/unity-ads-stopped-serving-ads-all-of-a-sudden-fill-rate-dropped-to-0.1255575/#post-8048303</a></p><p><a href="https://forum.unity.com/threads/fraud-deduction.1180543/">https://forum.unity.com/threads/fraud-deduction.1180543/</a></p><h4>So What Now If Not Unity Ads?</h4><p>I moved on the Google’s Ad mob and I couldn’t be happier. From my research the stacks are very similar so it would take you the same amount of time to add ads to your game using either solution. I’d recommend <a href="https://admob.google.com/home/">Google’s Ad Mob</a> and <a href="https://firebase.google.com/">Firebase</a> suite for other online services like remote config and analytics. They have been around way longer than Unity and do a better job with cloud services. Their fraud and customer support teams are also way better than Unity. I haven’t been blocked there but had both technical and organizational issues with them and the support team was at least human and responsive.</p><h4>Last Words</h4><p>I hope that no developer goes through the same experience as I did. But as the forum posts suggest, many are! As an indie developer you make little money to begin with. The last thing you need is for Unity, the entity that is supposed to support game developers, to pull the rug from under you.</p><p>If you have had a similar experience I’d love to hear it. Feel free to leave a comment or dm me.</p><p>As always, happy developing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=769ce62aaccb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Delete Microsoft Edge on Windows 10/11]]></title>
            <link>https://nosuchstudio.medium.com/how-to-delete-microsoft-edge-on-windows-10-11-f6a167553357?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6a167553357</guid>
            <category><![CDATA[edge]]></category>
            <category><![CDATA[uninstall]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[microsoft-edge]]></category>
            <category><![CDATA[browsers]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Mon, 07 Feb 2022 18:35:18 GMT</pubDate>
            <atom:updated>2022-02-07T18:42:10.363Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*EHGh820ZWtAfD47CDQRaLg.png" /></figure><p>If you are fed up with Microsoft shoving Edge down your throat like me, follow this simple guide to get rid of the Edge malware.</p><p>Windows doesn’t let you uninstall Edge. It is one of the “core” apps supposedly. Don’t worry there is nothing special about it. You’ll be just fine without it.</p><p>Open an elevated cmd prompt and go to the following folder:</p><p>cd %PROGRAMFILES(X86)%\Microsoft\Edge\Application</p><p>There should be a folder in there corresponding to the version of Edge you have installed. Mine was <strong>98.0.1108.43</strong> in Feb 2022. Go down that folder then “Installer”</p><p>There you can run from the cmd line:</p><pre>C:\Program Files (x86)\Microsoft\Edge\Application\98.0.1108.43\Installer&gt;<br>setup --uninstall --force-uninstall --system-level</pre><p>That should do the trick! Windows will still try to launch Edge from system UI such as start menu but it will fail. Great!</p><p>You can still repair Edge from the settings app. Go to Settings -&gt; Apps -&gt; Apps &amp; Features and search for Edge in the search box.</p><p>Happy malware free browsing!</p><h4>Rant Appendix</h4><p>Microsoft Edge is THE BROWSER for windows. “It is fast, reliable, secure, better than chrome, blah blah” Microsoft says. We have been hearing that since 2009 when Internet Explorer went under. Microsoft started constantly false-advertising IE 10 and 11 and Edge. Edge was initially just a reskin of IE. After that fiasco they surgically replaced the engine from TRINET (legacy engine dating back to 1990s) to chromium. Hopefully Microsoft will have some sense to replace the front with chromium too and just dump Edge.</p><p>After a decade of shoving a shitty browser down its loyal customers’ throats, I find it really hard to believe the 2022 version of Edge to be anything but disappointment. I haven’t tried it though but have too much negative emotional baggage from Microsoft to even give it a try. Plus Firefox, Chrome, Chromium and Thor browsers are fine browsers. Why bother?</p><p>While I have installed Firefox and have it as the default browser, Windows still opens Edge at any chance it gets. Whether it be a link in settings app or a search in the start menu. Ughghgh disgusting…</p><p>End rant. Back to work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6a167553357" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Programming Essentials: enabled vs active]]></title>
            <link>https://nosuchstudio.medium.com/unity-programming-essentials-enabled-vs-active-4114a4dbcabf?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4114a4dbcabf</guid>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Fri, 23 Jul 2021 00:19:35 GMT</pubDate>
            <atom:updated>2021-07-23T00:19:35.933Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*I8OY4lySlvmCveRIT8CReg.png" /></figure><p>In this post we explore two of the core concepts in Unity scripting. <em>Enabled</em> state of Unity Components (<em>MonoBehaviours </em>are example Components and we mainly refer to them when talking about <em>Components</em>) and <em>Active </em>state of Unity <em>GameObjects</em>. These concepts haunt pro Unity coders as well as beginners. Even after years of writing Unity code, I still run into problems related to these states. Let’s jump in!</p><h4>GameObjects vs Components</h4><p>It is important to understand the architecture of a Unity scene, specifically <em>GameObjects </em>and <em>Components</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TOSEv06O9vGHUMxMGCWkQ.png" /></figure><p>Blue: GameObject hierarchy in the scene.<br>Red: A Component on the “ParentCube” GameObject<br>Yellow: Set active state of GameObject<br>Green: Set enabled state of Components</p><p><em>GameObject</em>s populate a Unity scene and live in a hierarchies. Each <em>GameObject </em>has one or more Components attached to it. The hierarchy window shows the <em>GameObject</em>s in the current scene in their hierarchy. The Inspector window for a <em>GameObject </em>shows all the components that are attached to it.</p><p>A <em>GameObject </em>has a <em>Transform</em> component at least. You can add other components to it. When we code <em>MonoBehaviour</em>s in Unity, we are creating new <em>Component</em>s that we can add to our <em>GameObject</em>s later.</p><h4>Active State</h4><p>active is the state of a <em>GameObject</em> and can be toggled through the top checkbox in the inspector window or code. The method to set the active state is GameObject.SetActive(bool).</p><blockquote>A big source of confusion here is that when we talk about an <strong><em>active</em> </strong>object, we almost always mean <strong>activeInHierarchy</strong>.</blockquote><p>A <em>GameObject </em>is activeInHierarchy only if itself and all its parents are active.</p><p>You can check the active state of GameObject using 2 methods.</p><ul><li>ActiveInHierarchy is the actual property that tells us whether the <em>GameObject </em>is active.</li><li>ActiveSelf is the property that gets set through the Inspector UI or a script call to SetActive .</li></ul><p>The table below shows how these properties relate.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc688cd3da51ee2c39e8bf6e50d200a9/href">https://medium.com/media/fc688cd3da51ee2c39e8bf6e50d200a9/href</a></iframe><h4>Enabled State</h4><p>enabled is the state of a component and can be toggled through the Inspector window or code. If a component is enabled then it will have its Update and Start callbacks called. Note that other callbacks like OnTriggerEnter will get called even for a disabled component.</p><blockquote>A <em>Component </em>is enabled if the <em>GameObject </em>it belongs to is active and it is enabled.</blockquote><p>We can check the enabled state of a <em>Component </em>using 2 properties.</p><ul><li>enabled property is the actual property that can be set using Inspector UI or code.</li><li>IsActiveAndEnabled is a derived property and actually tells us whether the <em>Component</em> is enabled.</li></ul><blockquote>mono.IsActiveAndEnabled effectively equals to mono.enabled &amp;&amp; mono.gameObject.IsActiveInHierarchy</blockquote><p>Here is the full table showing how the states relate to each other. We can set the <em>enabled</em> state of <em>components</em> and <em>active</em> state of <em>GameObject</em>s.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d39f8e453839d4c16a575af5940b27ef/href">https://medium.com/media/d39f8e453839d4c16a575af5940b27ef/href</a></iframe><h4>So whats the big deal?</h4><p>Note that ActiveInHierarchy and ActiveAndEnabled are more recent properties which cleared things up. In 2018 and older you had to check for enabled and active using your own helper methods.</p><p>Part of the confusion about these comes from the documentation. When we talk about <em>enabled </em>components, we usually mean <em>ActiveAndEnabled.</em></p><p>For example the official Unity documentation for <a href="https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html">MonoBehaviour.Update</a> says: “Update is called every frame, if the MonoBehaviour is enabled.” Which is true for <em>ActiveAndEnabled</em> components.</p><p>Also have in mind that during events that affect these properties, they might be inconsistent. In a recent bug in Unity 2019.3, in a Coroutine I faced a state where for a MonoBehaviour’s ActiveAndEnabled was true while ActiveInHierarchy was false!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4114a4dbcabf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Download Older Unity Firebase SDKs]]></title>
            <link>https://nosuchstudio.medium.com/download-older-unity-firebase-sdks-b9e23123a6b4?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9e23123a6b4</guid>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[version]]></category>
            <category><![CDATA[old]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Mon, 19 Jul 2021 22:53:35 GMT</pubDate>
            <atom:updated>2021-07-19T22:54:49.663Z</atom:updated>
            <content:encoded><![CDATA[<p>The official firebase website has a link to download the latest version of their SDK for Unity. The page is <a href="https://firebase.google.com/docs/unity/setup">here</a> and links to the following URL.</p><blockquote>Download Latest Unity SDK<br><a href="https://firebase.google.com/download/unity?authuser=0">https://firebase.google.com/download/unity</a></blockquote><h4>Older versions</h4><p>To download older versions, you can use a direct link like below.</p><blockquote>Download arbitrary Unity SDK<br><a href="https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_X.YY.Z.zip">https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_X.YY.Z.zip</a></blockquote><p>For example to download firebase SDK version 6.15.2, the direct link would be:</p><p><a href="https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_X.YY.Z.zip"><em>https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_</em><strong><em>6.15.2</em></strong><em>.zip</em></a></p><p>This information came from <a href="https://github.com/firebase/quickstart-unity/issues/633">this Github issue</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9e23123a6b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Globally Shared Variables in Unity]]></title>
            <link>https://nosuchstudio.medium.com/globally-shared-variables-in-unity-33f60556ff8a?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/33f60556ff8a</guid>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[assets]]></category>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Fri, 09 Jul 2021 20:39:47 GMT</pubDate>
            <atom:updated>2021-07-09T20:40:09.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shared Variables in Unity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4SVIZs5JhtNZoej2kuonyQ.png" /></figure><p>Today I published <a href="http://u3d.as/2yyv"><em>No Such Studio: Variables</em></a> on Unity asset store. As the name suggests, this package let’s you create named variables that can be accessed from any script. This post will explain how the package works. It helps with some repetitive Unity tasks you encounter as a developer when dealing with shared variables. You need to know Unity’s component system and programming to use the asset.</p><h4>Background: Accessing Variables from Other Components in Unity</h4><p>Finding other components and calling methods on them is a common part of coding a Unity game. A typical Unity script has parts like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0ae8bb4b968abefab02f492b6788f5c/href">https://medium.com/media/a0ae8bb4b968abefab02f492b6788f5c/href</a></iframe><p>This enemy controller script adds to user coins when the enemy dies. The current code works for small projects. What if on top of the UI, we have a database that saves the current state of the game and a achievements class that checks whether the user has unlocked a new achievement because of the new coins? The code explodes in size if we keep doing the same thing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45dc9f92f09831a017c48608ac1c44dd/href">https://medium.com/media/45dc9f92f09831a017c48608ac1c44dd/href</a></iframe><p>Note that any code that wants to change coins would need to include the same setup and update code as above. Say we had a LevelManager class that would give coins at the end of the level. That class would need to have a copy of almost exactly the same code as above. Here are a few other typical places that user’s coins could change:</p><ol><li>login</li><li>a friend accepts their invitation request</li><li>watching an ad</li><li>unlocking a new achievement</li></ol><p>Imagine having to do the same amount of work for each of the above components. That would create a lot of repetitive code!</p><p>Hopefully this simple examples makes the case for needing a more robust and efficient way for managing shared variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*t8qaINpitE3iqA5L5zciAw.png" /></figure><p>To look at it in a more schematic way, each variable has:</p><ol><li><strong>Consumers</strong>: components that read and write its value. EnemyController and LevelManager on top of Database, UIManager and Achievements are consumers of <em>coins </em>variable in our example.</li><li><strong>Listeners (Observers):</strong> components which listen for changes to the variable. UIManager, Database and Achievements are listeners for the <em>coins</em> variables.</li></ol><blockquote>Listeners are almost always Consumers too!</blockquote><p>This pattern of multiple changes happening as a result of a value change is a well known pattern in programming. Events are a common pattern for dealing with that. Here is our above example written with an event for the <em>coins</em> variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd15505ca5403336f4bcc3a36729cf0d/href">https://medium.com/media/bd15505ca5403336f4bcc3a36729cf0d/href</a></iframe><p>Note that the consumers (EnemyController and LevelManager) now need only find the owner of the variable. That is easy with <em>singleton </em>pattern as is assumed above.</p><p>Note that similarly listeners (Database, UIManager and Achievements) need only find the owner of the variable and register with its event.</p><p>Using <em>events </em>the code becomes cleaner and more untangled. EnemyController no longer needs to know about all the listeners for the <em>coins </em>variable like UIManager and Achievements .</p><p>Events deal with the problem of wanting to do multiple tasks as a result of a variable change. However there is quite a bit of setup needed for each variable. Each listener needs to register for the event for each variable they are interested in. The sample code above is for a single variable named <em>coins. </em>What if we had <em>score</em>, <em>user_name</em>, <em>user_exp</em>, <em>user_items</em>, <em>etc</em>. <em>etc</em>.?</p><h3>No Such Studio: Variables</h3><h4>Who should use it?</h4><p>No such studio’s Variables asset streamlines the process of creating observable variables and listening for changes to them.</p><p>If you are a programmer and find yourself:</p><ul><li>Fixing Component references in Unity Editor or setting up events often</li><li>Dealing with errors that arise from null references and references to destroyed components</li></ul><p>then this asset is going to be a lifesaver.</p><p>If you don’t know programming and are using visual scripting assets like <a href="https://assetstore.unity.com/packages/tools/visual-scripting/bolt-163802">Bolt</a> and <a href="https://assetstore.unity.com/packages/tools/visual-scripting/playmaker-368">PlayMaker</a>, you don’t need this asset. They already contain observable variables in one form or another.</p><h4>How it works?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*kguW9ojbyVUABHC6ET8p4w.png" /></figure><p>With <em>No Such Studio: Variables</em> asset, you can use named variables from any script in your project. You need to create variables with unique names in VariablesSrouce components as part of setup.</p><p>After that, you can set and get variable values like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*wA5yxSL6Obvinmj3nU-ERQ.png" /></figure><p>Note that the methods are static and you don’t need to hook up any component references or events! It all happens behind the scenes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*PymE8RYU5qzcvtPg7PRJMg.png" /><figcaption>Editor Inspector for VariablesListener component</figcaption></figure><p>If you want to listen to changes to a variables, you can use the VariablesListener component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*4VLcbQhHcW2U2wdcAv_2lA.png" /><figcaption>Editor Inspector for VariablesService component</figcaption></figure><p>VariablesService component is the central hub for all the variable sources and listeners. It let’s you inspect all variables in your scene both at runtime and edit time in Editor. This makes debugging any issues with variables easy to track down.</p><p>All variables in <em>No Such Studio: Variables </em>have a string type for simplicity. You can however use any serializable type using extension methods that come with the asset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rlf1VCFnXbTTxSZMl1vzjg.png" /></figure><h4>Pros &amp; Cons</h4><p>Here are the benefits of using <em>No Such Studio: Variables</em>:</p><ol><li>No need to setup any component references and events! As long as we define the variable in a VariableSource component in the scene, any code can access it! <br>This means no more dealing with null or destroyed GameObjects, Components or events.</li><li>In cases that a variable is not declared, no exceptions will be raised. VariablesService prints out log messages for such cases, but won’t cause an exception.</li><li><em>No Such Studio: Variables</em> asset creates events internally for each declared variable and invokes the events when the corresponding variables change. So the code is as efficient as it gets!</li><li>No coding required for shared variables functionality.</li></ol><p>While this asset helps with cleaning up code and keeping things organized, there is one drawbacks when using it:</p><ul><li>No compile-time type safety! Using string type for variable names and their values could cause errors at runtime. Watch out for misspelled variable names!</li></ul><p>You can learn more about the asset and more advanced use cases like creating custom VariablesSource classes on the <a href="http://www.nosuchstudio.com/unitydocumentation/manual/variables/index.html">documentation website</a>.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33f60556ff8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GoPro HERO9 HERO8 Beep meanings]]></title>
            <link>https://nosuchstudio.medium.com/gopro-hero9-hero8-beep-meanings-561d7a1c2474?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/561d7a1c2474</guid>
            <category><![CDATA[gopro]]></category>
            <category><![CDATA[beep]]></category>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[gopro-hero-9]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Fri, 12 Feb 2021 05:55:25 GMT</pubDate>
            <atom:updated>2021-02-12T05:55:25.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*C_RNLP9Wz5WgN0PJ_49lUw.png" /></figure><p>This is a quick post on what the beeps mean on a GoPro HERO9. The beeps are the same on HERO8 and probably older versions. I don’t have older camera models so I don’t know.</p><p>You should be familiar with your GoPro and its functions. Consult the manual if you are not. The beep meanings are very important if you can’t see your camera’s screen when using it. For example if it is mounted on your helmet when skiing or mountain biking, you need to know what your camera is doing just by listening to its beeps. The manual explains how to control your camera in detail. It however doesn’t mention the beeps AT ALL!</p><p>I figured out these beeps and their meanings through trial and error and put them here. Hope it helps someone. If it does, clap!</p><h3>Power Button</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f98232f89c5e16c891e0496f24c0153/href">https://medium.com/media/7f98232f89c5e16c891e0496f24c0153/href</a></iframe><h3>Shutter Button</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a42ba1e9a2ad3d2a58a61fd79d7a4676/href">https://medium.com/media/a42ba1e9a2ad3d2a58a61fd79d7a4676/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=561d7a1c2474" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log Exceptions from C# Tasks to Unity Console]]></title>
            <link>https://nosuchstudio.medium.com/log-exceptions-from-c-tasks-to-unity-console-6e17ede5b5f2?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e17ede5b5f2</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Thu, 21 Jan 2021 19:37:39 GMT</pubDate>
            <atom:updated>2021-01-21T19:45:36.741Z</atom:updated>
            <content:encoded><![CDATA[<p>Unity prefers using Coroutines for asynchronous code. However there are times when you have to work with C# Tasks. In my case I am using Google’s Firebase SDK and that SDK uses Tasks. Tasks are great. They let you define blocks of code to run one after another (chaining) and decide what happens if a task fails, throws exceptions, etc. You can read more about them on <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task?view=net-5.0">Microsoft docs</a>.</p><p>A big aspect of Tasks that differentiates them from Coroutines is that they can run on background threads. Unity logs uncaught exceptions on the main thread to the console by default. A very handy tool for finding bugs in your code and fixing them. For background threads however, the exceptions will remain silent in Unity. This can cause weird issues in your code.</p><p>Another thing about Tasks is that they encapsulate both the code to run and the result of the execution. So if a task fails (as in throws an exception), it will catch the exception and prevent it from going up the stack. The task will save the exception so that any subsequent tasks or routines can examine what happened later.</p><p>Let’s take a look at a real example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dd132a39cb4d0dae994a8a900491a6f/href">https://medium.com/media/2dd132a39cb4d0dae994a8a900491a6f/href</a></iframe><p>TaskCompletionSource is a utility class for making tasks. We can control the task’s state using SetResult, SetCanceled and SetException. tcs.Task returns a Task.</p><p>Task.IsCanceled and Task.IsFaulted can be used to examine whether a Task ran successfully to completion or not. The if-else clause looks a bit cumbersome, specially since it needs to be written per task.</p><p>FromCurrentSynchronizationContext() makes the continuation to run on the same thread as the current Task. Since Start() is guaranteed to get called on the main thread in Unity, this will cause all code to run on the Main Thread.</p><blockquote>You can schedule Task continuations to run on the main thread more reliably by using <a href="https://firebase.google.com/docs/reference/unity/class/firebase/extensions/task-extension#continuewithonmainthread">Firebase.Extensions.TaskExtension.ContinueWithOnMainThread</a> (Firebase SDK). You can also use <a href="https://github.com/PimDeWitte/UnityMainThreadDispatcher">MainThreadUnityDispatcher</a> library from Github.</blockquote><h3>The Logging Problem</h3><p>Not let’s imagine the case where we set the task to run successfully but our setup is buggy and myObj field is null. Line 16 calls MyMethod on the Main Thread, yet line 6 never prints anything to console!</p><p>So out Unity console will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*xrSxib8C3CJhcvwRohw7dg.png" /></figure><p>How confusing! The simple 3 line code of MyMethod is not running to completion and there is no errors printed to console.</p><p>Note that if we call MyMethod from the main thread directly, not as part of a Task, we would get an error log with the exception info which would make it clear what was happening and WHY the code in MyMethod wouldn’t run.</p><h3>What is Happening?</h3><p>Line 5 throws an exception in both cases.</p><p>When MyMethod is called directly, the exception propagates up the stack till Unity catches it and prints it to the console.</p><p>When MyMethod is called from a Task on the main thread, the exception is caught by the Task and stored in the task object. Unity Editor will never see the exception.</p><h3>How to Fix This?</h3><p>The fix is simple in principle. We can do the same thing we did for our task to begin with. Check its result of our continuation task and print errors to console:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e8c344578cf23dbbc93a9c3ef4c72aa/href">https://medium.com/media/8e8c344578cf23dbbc93a9c3ef4c72aa/href</a></iframe><p>Now the console shows the exception just like it would if we weren’t using Tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*tNG83Q9lz9jZazOlOADHxQ.png" /></figure><h3>A Cleaner Solution</h3><p>Having to make a task continuation just to print errors to console will clutter our codebase. Let’s make an extension method for Task instead!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e020038c98a11db5e5ec3d027edb956f/href">https://medium.com/media/e020038c98a11db5e5ec3d027edb956f/href</a></iframe><p>Going back to our original code, we can rewrite it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/587f8db48a4687439964b00a8567a68a/href">https://medium.com/media/587f8db48a4687439964b00a8567a68a/href</a></iframe><p>Much more concise!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e17ede5b5f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Essential Shortcuts in Visual Studio 2019]]></title>
            <link>https://nosuchstudio.medium.com/10-essential-shortcuts-in-visual-studio-2019-c5c02660f236?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5c02660f236</guid>
            <category><![CDATA[cheatsheet]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[keyboard-shortcuts]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[visual-studio]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 22:15:53 GMT</pubDate>
            <atom:updated>2020-12-02T22:15:53.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xV3dkQgV719qwAIzUHuj_g.png" /></figure><p>Here are the most essential shortcuts I use to get things done quickly when using Visual Studio. I’m mainly coding C# for Unity on Windows these days but these shortcuts are generic and applicable to any programming language. This list of shortcuts is not exhaustive. Just the ones I use as a seasoned developer. At the end of this post I have included links to more complete lists.</p><blockquote>If you are on Mac or Linux, you probably use Visual Studio Code, the cross platform solution from Microsoft which is different than Visual Studio itself. Not all the functionality is available there so some of the shortcuts may not work or be different.</blockquote><h3>Auto Complete</h3><p><em>ctrl+space</em></p><p>Very basic but included for completeness. After . s and incomplete words press this shortcut and see VS has to offer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1td_z8Ah2whw2wfUYAq5RQ.png" /></figure><h3>Format Document and Sort usings</h3><p><em>ctrl+K, ctrl+E (format document AND sort </em><em>usings)<br>ctrl+R, ctrl+G (sort </em><em>usings)<br>ctrl+K, ctrl+D (format document)</em></p><blockquote>comma in the shortcuts means <strong>then. </strong>There are so many commands in IDEs today that they are categorized into groups that have their own shortcuts.</blockquote><p>One of the most useful shortcuts. Before committing to my version control (git), I run this on my edited files to get rid of unused usings statements and have them sorted.</p><h3>Go to Definition</h3><p><em>ctrl+click<br>F12</em></p><p>This is the key shortcut for navigating code. Often times we want to see the definition of a type, method or variable and this takes us directly there. Paired with <em>ctrl+-</em> to navigate back, it is a powerful shortcut to move around code.</p><blockquote>Doing this on override keyword takes us to the method definition in the parent class!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xu0QDWtW_tNneFbb5mCB-A.gif" /></figure><h3>Block Comment</h3><p><em>ctrl+shift+/</em></p><p>Use this to quickly comment out / uncomment blocks of code, methods or entire files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUDfe7PXyb8en0jfNkVDDw.gif" /></figure><h3>Semantic Find (Quick Launch)</h3><p><em>ctrl+Q</em></p><p>Use this to quickly find classes, files, etc. I use this all the time to go to a file I want to edit or find a class in my codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKFAQKkpZseW8EzSVKT8Lw.png" /></figure><h3>Find and Replace Text</h3><p>You can find and replace text in the current document or in the entire solution.</p><p><em>ctrl+F (find inline)<br>ctrl+H (replace inline)<br>ctrl+shift+F (find in files)<br>ctrl+shift+H (replace in files)</em></p><p>Inline UI is the compact panel that shows at the corner of the document. You can still change the scope to project, solution, etc.</p><p>“Find in Files” shows you a more elaborate UI for finding and replacing text in your document, project, solution, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dP7OTip9lG14nc1oTmmqYg.png" /><figcaption>Inline UI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9rsC0ZIU1zfMWB84nFCHw.png" /><figcaption>Windowed UI</figcaption></figure><h3>Smart Tag</h3><p><em>ctrl+.</em></p><p>Visual studio is pretty smart and suggests modifications and refactors to the code. Wherever there are red / yellow / green lines under your code, you can press this shortcut to see what the suggestions are. Even if there are no underlines, there may be options available in this menu. I use them only when they are red or yellow (error and warning levels).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eyhzNDS_F1KbelFwhDSaXA.png" /></figure><h3>Sync Current Document With Solution Explorer</h3><p><em>ctrl+[, S</em></p><p>This will select the current document in the “Solution Explorer” window and focus that window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBu-Sk1Ddw4MhI7a7u6YmQ.png" /></figure><h3><strong>Semantic Rename</strong></h3><p><em>ctrl+R, ctrl+R</em></p><p>Have your caret on the name you want to change. It could be a variable or a type (class, struct, enum, etc.) or method name. Your changes will be reflected on all the occurrences of that name in your solution.</p><blockquote>Use this when there are no compile errors. Visual Studio uses compiler references to know which names to change.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vCKdCR3XiEEvdVDlbRbsVg.png" /></figure><h3>Conclusion</h3><p>This list is by no means exhaustive. You can see a more comprehensive list of shortcuts on <a href="https://docs.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-for-frequently-used-commands-in-visual-studio?view=vs-2019">Microsoft’s website</a>. In Visual Studio you can open the options window (<em>Tools -&gt; Options</em>) and then navigate to <em>Environments -&gt;Keyboard. </em>There you can see the list of all available actions and their respective shortcuts and modify them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uO_eNM-iuf6y3M3WOw8Z3w.png" /></figure><p>I have been developing Software and using Visual Studio for 20 years and use these shortcuts to boost my productivity. If you use other shortcuts and tools in Visual Studio that help with your productivity, feel free to leave a comment and share them with the community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5c02660f236" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Unity Editor Scripting: Scene View (Part 6)]]></title>
            <link>https://nosuchstudio.medium.com/learn-unity-editor-scripting-scene-view-part-6-b1f9c0d9aff1?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1f9c0d9aff1</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[scripting]]></category>
            <category><![CDATA[editor]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Wed, 11 Nov 2020 14:03:16 GMT</pubDate>
            <atom:updated>2020-11-11T14:03:16.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*9JhigjFtHVFGDTaC33TQyQ.png" /></figure><p>In this post we will learn how to extend the Scene View, probably the most important Editor window in Unity! Things we do in this post:</p><ol><li>Show a gizmo for an invisible object from Editor code.</li><li>Create our own custom GUI in the scene view</li><li>Create a simple move tool to move our target objects around our game arena but make sure they are within the arena limits.</li></ol><p>This article is part of a series in which I explain all the techniques for extending the Unity Editor. <a href="https://medium.com/@nosuchstudio/learn-unity-editor-scripting-overview-part-0-1da6fe2552ba">See the overview post here</a>.</p><p><strong>Prerequisite:</strong> You need to know C# programming and be familiar with Unity Editor to benefit most from this post.</p><p>There is an accompanying Unity project. I highly recommend downloading it and trying the topics as you read them here. Seeing the examples in action makes them stick to your brain.</p><p><a href="https://github.com/hk1ll3r/UnityEditorScriptingTutorial">hk1ll3r/LearnUnityEditorScripting</a></p><p>For instructions on how to get started with the project, <a href="https://medium.com/@nosuchstudio/learn-unity-editor-scripting-overview-part-0-1da6fe2552ba">see the overview post</a>.</p><p>Without further ado, let’s jump in!</p><h3>Gizmos</h3><p>Gizmos are little icons that are shown in the SceneView for objects that don’t have a mesh. Camera, AudioSource, Text are sample objects that use Gizmos. Gizmos help us select these <em>invisible </em>objects from the SceneView rather than finding them in the hierarchy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*3gIejDso6Gy0HDY8iB7Bbg.png" /></figure><p>In our game, the Manager object is invisible but contains quite a bit of logic in it. Let’s add a Gizmo to it!</p><p>We can add a gizmo for a MonoBehaviour by adding the OnDrawGizmos method to the class. Let’s add the following to <em>GameManager.cs.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae50068d77ed7ca9ef0f1e5e1cde0462/href">https://medium.com/media/ae50068d77ed7ca9ef0f1e5e1cde0462/href</a></iframe><ul><li>Gizmos namespace contains helper methods for drawing different gizmos. In our case we want to draw a custom icon where our <em>Manager</em> object is.</li><li>The icon (<em>“managerIcon.png” </em>in this case), should exist under <em>“Assets/Gizmos”</em> path.</li><li>The last parameter tells Unity whether the icon should have a fixed size or scale with Camera movement. Unity’s internal components like Camera and Light use true by default, so we do the same here.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*wWY2tFgCI4p7hdHwK18w6w.png" /><figcaption>Our custom gizmo for our GameManager script.</figcaption></figure><p>Now we can select the <em>Manager </em>game object from the scene view by clicking the gizmo.</p><h3>Custom Scene View GUI</h3><p>Next, let’s create a simple GUI in the Scene View to change the size of our arena. This could make it easy for our developers to set the arena size to standard sizes we want in our game.</p><p>To create GUI in the Scene View, we have to create a OnSceneGUI method in our Editor script. So let’s add the following method to <em>GameManagerEditor.cs.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a7395ece8925e4a4132ca9001552de3/href">https://medium.com/media/1a7395ece8925e4a4132ca9001552de3/href</a></iframe><ul><li>In lines 3 to 6 we get the current SceneView instance and compute a Rect to show our custom GUI in.</li><li>Handles namespace contains helpers for adding controls to the Scene View.</li><li>Handles.BeginGUI() creates a container for IMGUI. Every IMGUI call between Handles.BeginGUI() and Handles.EndGUI() will show in our Scene View.</li><li>Lines 7 to 19 are IMGUI calls to show 3 buttons that will set the size of the Arena object in our Scene and adjust the camera’s position to contain the arena.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAc70wvtOlDpqfxwJbNviQ.png" /><figcaption>Medium sized arena</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHG_LKLShzp_jRWw3FFOgA.png" /><figcaption>Small sized arena</figcaption></figure><p>A. Similar to the OnInspectorGUI() method, OnSceneGUI() method gets called only when the Inspector for the object is open.</p><p>B. Our GUI for adjusting the size of the Arena.</p><h3>Move Handle for Arena Object</h3><p>A <strong>Handle</strong> in Unity terminology is an interactive 3D object in the Scene View. The scale and move controls are example handles. That’s the reason for the name of Handles namespace.</p><p>We used Handles namespace in the previous section to create a <em>container</em> for our IMGUI calls. We can use its helpers to draw 3D objects and even 3D handles like the move and scale handles. It is possible to create custom handles beyond the ones already defined by Unity. If I get time I’ll make a post on that. In this post, let’s use the move handle from Unity.</p><p>Add this line to the end of OnSceneGUI method of <em>GameManagerEditor.cs.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/879bf74ee73f4bcb6428bf5a4d7e73bd/href">https://medium.com/media/879bf74ee73f4bcb6428bf5a4d7e73bd/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*3onKo2n-6oBjIc1C58Hssg.png" /></figure><p>Note that while the <em>Manager </em>object is selected, a second move handle is shown for the <em>Arena</em> object. You can move either object using its corresponding handle.</p><h3>Conclusion</h3><p>In this post we learnt about multiple ways to extend the SceneView’s functionality:</p><ol><li>Show a gizmo from our Editor code.</li><li>Create custom GUI in the SceneView.</li><li>Use Handles for modifying objects in the SceneView.</li></ol><p>If you have any questions and suggestions about this post, feel free to leave a comment.</p><p>If you find this tutorial useful, please support me on <a href="https://www.patreon.com/nosuchstudio">Patreon</a>. It takes a good amount of time to write these tutorials and your support will keep me going. Thank you!</p><p>This is the last post in this series. You made it! There is a lot more to learn about Unity Editor Scripting. This series lays the foundation on how to do it. Here are a few topics to read on if they apply to you:</p><ul><li><a href="https://docs.unity3d.com/ScriptReference/SettingsProvider.html">Adding custom settings to Unity’s project settings page</a>.</li><li><a href="https://docs.unity3d.com/2019.3/Documentation/Manual/UsingCustomEditorTools.html">Creating a proper Unity Editor tool.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1f9c0d9aff1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Unity Editor Scripting: Editor Windows (Part 5)]]></title>
            <link>https://nosuchstudio.medium.com/learn-unity-editor-scripting-editor-windows-part-5-2f7ac9f3415b?source=rss-f77c2f8234a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f7ac9f3415b</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[editor]]></category>
            <dc:creator><![CDATA[No Such Dev]]></dc:creator>
            <pubDate>Wed, 04 Nov 2020 14:03:22 GMT</pubDate>
            <atom:updated>2020-11-04T14:03:22.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*cD2h12X4QbIIzwFIN54Mzw.png" /></figure><p>In this post we will learn how to create our custom editor windows in Unity. <em>console</em>, <em>project view</em> and<em> asset store </em>are samples of editor windows.</p><p>This article is part of a series in which I explain all the techniques for extending the Unity Editor. <a href="https://medium.com/@nosuchstudio/learn-unity-editor-scripting-overview-part-0-1da6fe2552ba">See the overview post here</a>.</p><p><strong>Prerequisite:</strong> You need to know C# programming and be familiar with Unity Editor to benefit most from this post. You also need to know either IMGUI or UIElements for creating GUIs in Editor. In this post I will use IMGUI.</p><p>There is an accompanying Unity project. I highly recommend downloading it and trying the topics as you read them here. Seeing the examples in action makes them stick to your brain.</p><p><a href="https://github.com/hk1ll3r/UnityEditorScriptingTutorial">hk1ll3r/LearnUnityEditorScripting</a></p><p>For instructions on how to get started with the project, <a href="https://medium.com/@nosuchstudio/learn-unity-editor-scripting-overview-part-0-1da6fe2552ba">see the overview post</a>.</p><p>Without further ado, let’s jump in!</p><h3>Creating an Editor Window</h3><p>Create a new file named <em>MyEditorWindow.cs </em>under the <em>Editor </em>folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/985972dd3a38e73ccf0326edd81cc5bd/href">https://medium.com/media/985972dd3a38e73ccf0326edd81cc5bd/href</a></iframe><p>Code explanation:</p><ul><li>Our class needs to extend the EditorWindow class.</li><li>We are using the MenuItem attribute which we learnt about in the previous post to show a menu item to toggle our window.</li><li>Line 15, myWindow.titleContent sets the title of our window. By default Unity uses the fully qualified name of the class which in our case is <em>NoSuchStudio.ExtendingEditor.Editor.MyEditorWindow</em>. Here we change it to <em>“My Window”</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*Rgdf9jM-jKyK3WDVVOWSqA.png" /></figure><ul><li>My Window menu item will show our window if it is hidden, or hide it if it is already being shown.</li><li>GetWindow&lt;T&gt; gets an editor window of type T if one already exists. It will create and show a new one if one doesn’t already exist.</li><li>EditorWindow.Close() closes an editor window.</li><li>OnGUI is the message similar to the one in MonoBehaviour. We define our own GUI in that method.</li></ul><p>For now our Editor window doesn’t show any useful GUI, but otherwise can be moved around, resized and docked like any other editor window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*OS3oGqieUyehW3Czd_b_Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*fKJ83BtkcXPCn9rsh2fcUg.png" /></figure><h4>Adding GUI to Our Window</h4><p>We can use either <a href="https://docs.unity3d.com/Manual/GUIScriptingGuide.html">IMGUI</a> or <a href="https://docs.unity3d.com/Manual/UIElements.html">UIElements</a> to create our UI in an Editor Window. Let’s stick with IMGUI which we have used so far in this series.</p><p>Change the code in OnGUI method to the following in <em>MyEditorWindow.cs.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d9081a952644715b668a2bec950126e/href">https://medium.com/media/7d9081a952644715b668a2bec950126e/href</a></iframe><p>You should be able to understand what’s going on. I’ll make a post on IMGUI later and put a link here.</p><p>In any case, our window now shows some basic stats about the level like the number of targets, total score and the surface area of the arena.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*lrkPNeOLaw2nfYPyLnAhUQ.png" /></figure><h3>Conclusion</h3><p>In this post we learnt how to create an Editor Window in Unity and show / hide it.</p><p>If you have any questions and suggestions about this post, feel free to leave a comment.</p><p>If you find this tutorial useful, please support me on <a href="https://www.patreon.com/nosuchstudio">Patreon</a>. It takes a good amount of time to write these tutorials and your support will keep me going. Thank you!</p><p>In the next post, we will see how to interact with the Scene view and show our custom gizmos and UI there. (ETA Nov 18th 2020).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f7ac9f3415b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>