Thursday, November 7, 2019

First MindTrust Game [Survey]

We are working on our first internal title and since we have a short budget we want to prioritize features. In order to help us focus we'd your help by answering this short survey. For those interested, I plan on posting the results here on my blog at the end.

https://forms.gle/oGrhdQWSH4kN8xvT8

Hint: It involves a monkey, a pig, and some catchy lyrics. :)  Here is a sneak peak at the art:


Saturday, June 1, 2019

New Company, New Role, Now Hiring

I am excited to announce I am taking on a new role as the Director of Games/XR for MindTrust Labs (https://www.mindtrustlabs.com/). One of my first tasks is to expand the team to handle upcoming client projects. While we will initially be focused on creating games and XR experiences for clients, our longer term goal is to release our own IP.

The team is remote, Unity based, and comprised of a mix of industry vets along with aspiring game creators.

I am currently focused on filling the following remote positions:
Art Director (Full Time - Industry Vet Required)
3D Artist (Full or Part Time)
Technical Artist (Full or Part Time)
Back End Engineer (Full or Part Time)
Data Scientist & Monetization Strategist (Part Time - Industry Vet Required)

All interested parties should send links to their portfolio and CV to mgrossnickle[at]mindtrustlabs[dot]com.

Monday, March 25, 2019

Custom Local Packages - Unity Package Manager


At Taqtile we are big proponents of re-using our code base across multiple projects.  In the past I wrote about how to share code between Unity projects via SymLinks.  The main problem with that solution to sharing code is that it is not supported by Unity.  It works fairly well for code but issues can arise when you try to share prefabs/assets as guids can conflict across projects.  We put up with it though because it was the best solution we could find to bring in external code. Until now that this is!

Unity 2018.3 and 2019.1 are bringing big changes to how Packages work in Unity.  I currently have a use case of needing to bring in an extension from the Mixed Reality Toolkit (MRTK).  Currently extensions reside in a sub directory within the MRTK library.  I haven't ported our projects over to MRTK yet so I don't want to bring in the entire library into my project; therefore, in this blog post I'll be exploring how to bring just the extension into my project using local Packages rather than symlinks.

Benefits
The main benefit of using packages instead of symlinks is that it is supported by Unity.  In theory, you should be able to bring in all types of assets without guid conflicts.

The main benefit of using packages instead of asset bundles is that you do not need to export the code.  You set it up once and then all future changes should be handled by the package manager.


Unity 2018.3 Solution
The ability to bringing in custom local packages was added in 2018.3, but it has limitations and is not documented.

The best documentation I could find for it can be found in this forum thread.  It goes into further detail than I will here but it states the package manager supports bringing in packages directly from git, the web, and local files.



Git is very interesting but it currently does not cache results and each time a change is made you would have to re-clone the entire library.  That is a deal breaker for me as speed during development is important. I'm also curious if git support would allow pulling in sub directories like my current use case or if I would have to pull in the entire MRTK.

For my immediate use case, I'll be focusing on the file scheme.  To get the file scheme to work you need to do two things:

1. Create a package.json in the directory you would like to share.  The package.json should have the following format:

{
 "name": "com.mrtk.webrtc",
    "displayName": "MRTK WebRTC Extension",
    "version": "0.0.1",
    "unity": "2018.3",
    "description": "Add description here",
    "keywords": ["key X", "key Y", "key Z"],
    "category": "MRTK Extension",
    "dependencies": {
    }

}

In my use case I placed the package in the following directory:
MixedRealityToolkit-Unity-WebRTC\Assets\MixedRealityToolkit.Extensions\Webrtc


2. Add a link to that package as a dependency in your manifest.json of the project you would like import the code into. The manifest.json can be found in the Packages folder of your project. Here is an example:

{
  "dependencies": {
    "com.mrtk.webrtc": "file:../../MixedRealityToolkit-Unity-WebRTC/Assets/MixedRealityToolkit.Extensions/Webrtc"
   }
}

Each entry is "package name": "path".  Note the "file:../../".  This allows everyone at Taqtile to use this solution without requiring each PC to have the same file structure.

There is also a button in the package manager that allows you to select your local package.json and import it directly to your manifest.json.  I thought this was only a Unity 2019.1 feature as I saw no mention of it in the forums but I noticed it while taking comparison screenshots.

If you use the + symbol in the UI to import your package then you may need to check the manifest.json after doing so because the path it filled in was absolute for me.




Unity 2019.1 UI Improvements
Note the new placement of the plus button:








The Future and Beyond
It appears Unity is going to continue adding features to the package manager to make this more robust and user friendly. The ability to select/manage local versions as well as nuget integration were the two most exciting offerings I saw mentioned as possible road map features.  No promises though.

Thursday, January 24, 2019

Backporting Unity 2018.2 to Unity 2018.1

First off, I don't recommend back porting Unity projects as it usually never ends well.  Your best bet is to revert your repository to a date prior to updating Unity.  That said, sometimes it is unavoidable.  In our case, we updated to Unity 2018.2 awhile back for a Hololens project.  Then we were asked to port the Hololens application to Magic Leap which currently is only supported in a technical preview on 2018.1.  We've done too much development on 2018.2 for reverting to make sense so here we are.


Step 1:
Close Unity and delete the Library folder within your project as well as any build folders and other temporary folders.  The Library folder is important as you may experience the editor crashing while trying to run a project in 2018.1 with cached properties from 2018.2.  The build folders were throwing some access denied errors for me but that may be specific to UWP and probably not as important for most projects.

Step 2.
Open the power shell and navigate to your project folder. Enter in each of these four commands 1 at a time.  Note, these are compiled from a few stackoverflow answers which I am having trouble finding at the moment to link credit to.


$configFiles = Get-ChildItem . *.prefab -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_IsPrefabAsset", "m_IsPrefabParent" } |
     Set-Content $file.PSPath
 }


 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_IsPrefabAsset", "m_IsPrefabParent" } |
     Set-Content $file.PSPath
 }


 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_SourcePrefab", "m_ParentPrefab" } |
     Set-Content $file.PSPath
 }


I did not find any references to this last one online, but I ran into some issues with prefabs within the scene losing reference and this fixed it.

 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_CorrespondingSourceObject", "m_PrefabParentObject" } |
     Set-Content $file.PSPath
 }

Step 3:
Cross fingers and give 2018.1 a try!  You may have a few coding changes to make if you did not use macros to separate out builds. 

Example:
#if UNITY_2018_2_OR_NEWER
// put unity 2018_2 code here
#else
// put unity 2018._1 and below code here
#endif


Good luck!

Wednesday, November 21, 2018

Unity3D Interview Preparation

Over the past 13 years I’ve seen my fair share of the interview process from both sides of the table. The following tips can be applied for a variety of technologies but are mostly geared towards those interviewing for full time or contract Unity3D developer positions.
The hiring process can usually be broken down into four main hurdles:
  1. Introduction
  2. Quick Assessment
  3. Thorough Assessment
  4. The Offer
Step 1: Introduction
Unity3D jobs are typically for highly desirable positions such as game development or virtual reality. This means that the competition can be fairly intense for a good Unity3D contract or full time position. In order to move forward in the interview process you are going to need to stand out from the masses by using your portfolio, resume, and cover letter. Resumes and cover letters are pretty standard for most industries; there are a plethora of resources online covering them so I’ll hit one point on each and then focus on the Unity3D portfolio.
One item I would make sure you do not overlook on the resume is to ensure it is in a file format every OS can easily view such as PDF. It can be frustrating for an employer to try to open a ‘Pages’ document on their PC only to have it missing fonts and oddly formatted due to file conversions.
One Item I would make sure you do not overlook on the cover letter is to actually write one. I realize it is much easier to just send in a resume but the cover letter is your big chance at selling yourself. You should research the company you are applying for and tailor your letter to their ideals and needs. This is your chance to highlight your past experiences that exemplify the skills they are seeking. If you can not muster up the energy to write a cover letter for a potential job then that job may not be right for you. Ideally, you should feel excited about the job and your excitement should show through in your cover letter.
While the cover letter and resume are important, it is the portfolio that will move you past this step for a Unity3D job. I taught an entire course called ‘Online Portfolio’ as an adjunct lecturer at Butler University. We can’t go over everything here but the key points are to showcase your past work, clearly define your contributions, and ultimately prove you would be an asset to their team. A portfolio can be anything from an interactive website with examples they can download and play to a document with screenshots and brief paragraphs describing a few projects and your contributions. If you do not have any projects to share then it is time to dive into a hackathon or start a hobby project. Additionally, if you have code you are allowed to share I’d also include a link to your github as part of your portfolio.
Step 2: Quick Assessment
If you successfully complete step 1 then you will typically be asked to complete a phone interview or an online test. In both of these cases the company is trying to vet you to make sure you are worth the time and money for a more thorough assessment. This is especially true for out-of-state interviews as an onsite in that case can be costly.
Phone interviews and online tests typically involve technical coding challenges. The best thing you can do is practice. There are sites available for this such as HackerRank that provide coding challenge examples. All of the ones I have tried include a C# option so they can be applicable to Unity3D. Go through as many as you can leading up to the test as you can never over-prepare. Try to cover common data structures, search algorithms, and sorting algorithms, as well as the pros and cons of using each.
Besides general coding you will also want to brush up on your Unity specific topics. Here are some examples of things you should know: Asset Bundles, batching, coroutines, draw calls, scriptable objects, shaders (fragmented versus vertex), culling, debugging, and profiling. Debugging and profiling is my favorite topic to question when I am interviewing a potential hire. I want to make sure you know how to troubleshoot issues. Do you know how to add breakpoints in your IDE? Do you know how to diagnose frames per second spikes? Do you know how to track down a memory leak? If you answered ‘no’ to any of these questions then take some time to research profiling and debugging before your next interview.
Lastly, review some design patterns that are commonly used in Unity3D. ‘Object Pooling’ is a great pattern to reduce instantiation hitches. ‘Chain of Responsibility’ is used in most input systems to prevent multiple colliders from being triggered on the user interaction events. ‘Observer’ is commonly used to listen for events dispatched by low level objects such as an enemy being destroyed. ‘Factory’ is often used in user interfaces to build out common elements like lists for leaderboards and inventory selection screens.
Step 3: Thorough Assessment
If you made it to this point then they are interested and you are most likely one their top few candidates. They will either invite you to an onsite and put you through some white boarding or they will give you a small project to complete over the next couple of days.
If you are given an onsite then you will want to buy the following book and work through examples from each chapter. I did an onsite at Amazon and was amazed that two of the four interview questions were pulled directly from this book: 'Cracking the Interview Code'. You should also be aware that they aren’t just judging your code. They also are judging whether or not you fit the job and the team. I passed the technical portion of an interview at Facebook but then was turned down because they didn’t think I wanted the job. It was true too. I was more interested in another company but I was surprised that I made it obvious to them during my interview. Lesson learned, how you act is just as important as what you say. Make sure you show an interest in the company, its employees, the project, and ask a ton of questions.
If you are given a project then this is your chance to show off. Over the years I have had to remake Asteroids, build a variation of Donkey Kong, create a slot machine, and a trivia quiz. When given a Unity3D project to complete you should first read their requirements very carefully and make sure you hit each bullet point. They will be judging you not only on the final product but also what is under the hood. Break down the challenge into classes and take extra care in how you use inheritance and composition to adhere to S.O.L.I.D. object oriented design principles. One key is to separate data logic from the view by using scriptable objects. Another is to ensure your project and scenes are organized and variable names and methods are named appropriately. As always, comment your code and ensure it is easy to follow.
If you have time at the end then sprinkle on a bit of love into the project. The asteroids challenge I was given was for EA’s Playfish Studio. I decided to make it an underwater asteroid game using their fish logo as the ship. The trivia quiz challenge was given to me around Halloween so I made it themed around classic scary movies and even added a cheap scare at the end using a screaming clown face. These touches go a long way in standing out compared to the other candidates.
Step 4: The Offer
Throughout the entire process you should be making sure the company interviewing you is a good fit for you. The offer is where you really get to turn the tables and have them sell you. For example, they will most likely ask you what you currently make. Try your best to avoid answering that question and instead answer the real question which is how much do they need to offer you in order for you to take the job. This can be a difficult question but you can get a decent idea of how much you are worth by visiting sites such as ‘Glassdoor’ or browsing similar job posts on sites such as ‘Angel’ that include salaries. I tend to have two numbers in mind: my ideal and my bottom floor. Answer their salary question with your ideal and don’t settle for lower than your bottom floor. Sometimes it is good to request a general ballpark earlier in the interview process. After spending a couple days on the Halloween Trivia challenge, I was offered a salary half of what I was making at the time. Had we discussed ballparks earlier on it would have saved me a couple days of work.
Conclusion
Preparation for Unity3D interviews is similar to most technical jobs with the addition of the portfolio as well as brushing up on some key Unity3D concepts. Regardless of whether or not you land the job you want, learn from the experience and take it to your next interview. If you take the attitude of continuously learning, improving, and adding to your portfolio, then you will eventually succeed at landing a Unity3D contract or position.

Friday, May 12, 2017

Keyboard based Debugger for Unity3D Projects

There is nothing complex here but I've found the following code extremely useful to quickly test functionality without having to mock up buttons. All you have to do is add this component to a GameObject then select Keycodes that you would like to pair with functions. You can also flag whether you want this to only occur in the editor or if you want to leave it for live production.

I'd like to get in the habit of posting more code. I tend to avoid it as anything interesting to me is usually overly complex or client specific. That said, if you found this snippet helpful I'd love to hear from you and I'll keep posting bite sized components that I find useful.

Example of the component:


Code:
 public class KeyboardCommandManager : MonoBehaviour
    {
        [System.Serializable]
        public struct KeyAndResponse
        {
            public KeyCode Key;
            public UnityEvent Response;
            public bool EditorOnly;
        }

        public KeyAndResponse[] KeysAndResponses;
        private List<KeyAndResponse> ActiveKeys;

        private void Awake()
        {
            ActiveKeys = new List<KeyAndResponse>();
            if(KeysAndResponses!=null)
            {
                for (int i = 0; i < KeysAndResponses.Length; i++)
                {
                    var keyAndResponse = KeysAndResponses[i];
                    if(!keyAndResponse.EditorOnly || Application.isEditor)
                    {
                        ActiveKeys.Add(keyAndResponse);
                    }
                }
            }
        }
 
        void Update()
        {
            if (Input.anyKeyDown)
            {
                 
                    for (int i = 0; i < ActiveKeys.Count; i++)
                    {
                        var keyAndResponse = ActiveKeys[i];

                        if(Input.GetKeyDown(keyAndResponse.Key))
                            keyAndResponse.Response.Invoke();
                    }
                 
            }
        }
    }

Thursday, May 26, 2016

Sharing code between Unity3D Projects

Here at Taqtile we are working on multiple Hololens projects at once and would like to create a core library for overlapping features such as an adjustable window to place or custom interactibles.

Unity3D does not natively support external folders but I found a few workarounds:

SVN Externals
This stackoverflow answer seems like the best solution but relies on SVN but unfortunately we are using Git.

Git SubTrees or SubModules
A submodule seems to be the closest thing to an SVN External but it is more of a reference to the code path at certain point in time. SubTrees are a complete copy. Neither seem ideal since we'd like to be updating the core library continuously. While you can rig both to commit and update via command prompt, most of our team uses software such as GitHub, Tortoise, and SourceTree and support seems limited or non-existent.

If you happen to have one of these solutions working on Git software with a GUI for non-technical team members I'd love to hear about it in the comments.

SymLink
The solution we landed on was Symbolic Links. A symbolic link is a Windows feature to make a folder that is located in one directory to appear to be located in another. Here is a tutorial on creating Symbolic Links.

But it is as simple as running the command prompt and running the following from a relative address:
mklink /J .\Assets\TaqtileTools ..\TaqtileHoloTools

You can even make a .bat file and commit it to the relative directory so anyone setting up the project for the first time just needs to execute the bat.

Note, given that Hololens is solely a PC environment at the moment we can safely assume the entire team will be running Windows. However, Mac users could create something similar as well.