Upgrading TextMesh Pro from an old Unity project

So If you are like me, you have a bazziloin projects you started, some you have finished and even some you have published. If you have made good money on your published projects, please tell me how! It’s almost the bane of a creator’s life to not get equally rewarded for their work… until you are dead I guess. Honestly, we live in an age that rewards creativity more than ever before (I think). Regardless of whether we made money or not, we still do it. We do it because it’s cool and we love it.

To that end, I have been bringing out some projects from the archives and upgrading them. These projects are mostly from the Unity 5.x time period (seems like forever ago!) The biggest issue seems to be migrating to the package manager included version of TextMesh Pro. You can spend weeks of your life rebuilding text prefabs. Thank goodness, the good folks at Unity have included a little tool to help. Im using Unity 2018.2.8f1 FYI. You can find this TextMesh Pro tool from Window -> TextMeshPro -> Project Files GUID Remapping Tool.

And this tool looks like (Yea I have Unity Pro! I do it just for the dark skin because I love my eyes!)

 

Now it’s tricky getting to…




Unity Debug Diaries

Performance Myth Busters: Variable Allocation

In Unity Performance Myth Busters I take an assumption and check if it’s still valid or just programming superstition. There is nothing like proof to end an argument or inform a decision. Plus, there is nothing like being humbled by a junior dev because you did not do your homework! Today, I want to chat about local variable usage in an update loop. So, you have all seen a loop like this:

private void Update(){
Vector3 eularRotation = assetToRotate.localEulerAngles;
eularRotation.y += Time.smoothDeltaTime * 10f;
assetToRotate.localEulerAngles = eularRotation;
}

So I created a project to test my theories. I am running on a MacBook Pro, Unity 2017.3.1f1, compiling for Mac standalone. At first, I run it in the editor with the profiler and we are getting the typical GC sawtooth curves. But as we know, profiling in the editor is a lie. Profiling a build, GC is a flat line! No change what so ever. That’s great news but is it only that the change is so tiny, we cant notice? Possible.

Next, I ran 64 instances of my test… and that was a flat line too. Before I bust this myth though, I want to make super sure so we are going to try 100k instances… because I can… and for science. Yea, that was a little heavy-handed. Let’s try 20k.

So after 20k instances of the above code, I can safely say local variable assignments does not generate garbage. Solid like a rock and myth busssssted!

All my Performance…




Unity Debug Diaries: Camera Glitch in Unity VR

I have been doing a bunch of VR work lately and working with the Gear VR in particular. The Gear is actually a nice piece of kit and I can’t wait to get my hands on the Oculus Go coming out… soon. As of this post, the Gear VR has the largest market penetration of any VR headset. One bug that I encountered that was tricky to nail down, was an optical glitch when moving from one part of my app to the next. It looks like an uninitialized RenderTexture, different every time and with glitchy artifacts everywhere.

Turns out the culprit was render scale, now known as XRSettings.eyeTextureResolutionScale. ETRS (because I’m not typing it out every time) is great for getting “free” anti-aliasing on everything in your scene. It basically renders at whatever ETRS is set to (eg:1.0, 1.2) and then downscales to 1 for the final blit. Since its a downscale (bilinear I think), its best never to exceed 1.5 or things will start to look crunchy. If you just want to downscale, use XRSettings.renderViewportScale, which is way cheaper than ETRS. It can only accept values from 0 to 1, hence downscale. By doing this, you would trade visual fidelity for performance.

Back to the issue at hand, changing eyeTextureResolutionScale at runtime will cause a new texture set to be made for each camera, and those textures are uninitialized. That means that it has been allocated space in memory, but whatever was occupying that memory is still there. This creates the weird memory artifacts that you see for…




Unity Debug Diaries

Linear & Gamma Color Space in Unity & VR

Color space will come up sooner or later in your journey through game development. Unity has many great resources about this topic so it’s really futile for me to try and do it better. What I will do is give you the synopsis. Gamma is the old way and Linear is new. Use linear colorspace where ever you can. Its supported by most new GPUs and screens. On mobile, its supported on OpenGL ES 3+. The catch is, as of the time of this doc, mobile VR and especially, the GearVR. Turns out that there is a known issue, found on this Oculus thread, with the Qualcomm divers on Android. So Oculus, both in person and on forum encourage you to use Gamma for GearVR and Go.

That’s not all though. If you are like me and you are switching branches in GIT often, the Unity color space setting sometimes does not stick. This was especially evident in a recent project where we upgraded to 2017. In Unity 5, the color space setting had been changed a couple of times but what we were seeing as linear was not actually correct. When we did the upgrade, the color space was still strange until we toggled the setting. So if your color looks weird, toggle that setting first before you do a major overhaul.




Unity3D Pro Tip

Unity Pro Tip: Gradient Property Color Stepping

An example of the fixed color step of the gradient property.

Unity updates fast and furiously and one thing you might have missed is the Gradient property update. With them already working on 2017.2, they have been busting it out! With this breakneck pace, you will undoubtedly miss some the coolness. Now, commercially, I am still on 5.6, but that just got released this year so I don’t feel too bad. Plus, there are a bunch of issues I encountered migrating to 2017 with Text Mesh Pro. So, if you are going to start a new project, go for it but I warn you, migrating existing projects will be a pain.

One of the little things you can find in 5.6 and above that is super useful is the upgrades to the Gradient property. Most commonly found in the Particle System component, the Gradient property can handle the linear interpolation of up to 8 colors. It also handles the interpolation of alpha separately with the same 8 key limit but on a separate track, meaning it’s not tied to the color keys. If you have not already used it for something else, consider it! As a programmer, you can expose color transitions for artists and game designers by just adding the field! It uses the same evaluation method as the curves property. Just call “myGradient.Evaluate(0.5f);”, 0,5f being the time or ratio. It serializes to boot, so great for JSON but it does create more data than you would think.




Unity Debug Diaries

Unity Debug Diaries: Unity & Apple TV

So I have been doing some initial tests using the Apple TV and so far so good. If you have gotten into the Unity Apple TV beta then you know the score by now. The current beta program has a modified version of Unity 5.1 that includes Apple TV as an iOS device in your build settings. If you want into the beta program, contact your local Unity rep and see what they can do. To get in we had to actually bug David Helgason, so I am not saying it will be easy but there is something really cool about having your stuff up on your big screen.

Right, now for the lowdown. I had 2 major problems, input and plugins. To get my initial build to work I had to strip out all my plugins… everything that had a call to external iOS functionality, even the ones built into Unity. Don’t worry about your internal plugins, things that exist with in the engine and player, they should be fine. tvOS support. So your first step in getting a build running on your Apple TV would be to

Update all your iOS plugins.
Systematically make builds and test on device, ripping out each plug-in until it works. If you read the XCode error message it will always point you to the offender.

Once you build successfully, its time to deal with your input. Unity has allowed for two main ways of dealing with input. 1) You can treat the remote like a game pad or 2) You can use the touch input…




Hyperkinetic Studios

Collective Mass Radio #16: Rich Bisso of Hyperkinetic Studios

As always, check out the rest of the blog as well as the other Collective Mass Radio podcasts on the site. A huge shout out to Rich Bisso and Hyperkinetic Studios for taking the time to talk to me and check out their work at http://www.hyperkineticstudios.com. Rich has been an avid supporter of the game creators community since I met him. He has always been super friendly and helpful to all who cross his path and consistently throws the best GDC parties ever!

 




Unity Debug Diaries

Unity Debug Diaries: Mip Map Memory Reduction

First off, I must apologize for the weird tense swapping that happens in these articles. I write stuff as it happens and do not want to do too much editing lest these become too tedious to write and then I just stop completely. So if you can deal, I will continue to write 🙂

Today, I am attacking using Mip Maps on UI for multi-resolution rendering. Enabling Mip Maps and managing which of the maps are loaded into memory is the easiest way to handle texture memory on lower end devices. Now, I believed this but did not see the reduction in the profiler on device. So then I figured it was a fallacy because the data suggested otherwise. I then switched to TK2D to handle a lot of my multi sized sprites but the lack of clarity on the issue always bugged me. So now, I want to find out for sure. I cant get a straight answer out of anyone so its time to set up some tests.

First, I am going to make a separate project in iOS to have a clean environment and have nothing muddy my results. I am choosing iOS because its got its own set of profiling tools that will help me isolate if the Unity Profiler is telling porky pies (lies).
Results: Lies lies lies! So profiling in iOS showed a radical drop in memory based on the appropriate quality settings. I have four 2048×2048 at 32 bit. The results in the profiler are:

Full resolution: 107.66mb
Half resolution: 43.68mb
Quater resolution: 27.69mb

These results…




Unity Debug Diaries

Unity Debug Diaries: Radically long load time on Kindle Fire HD

One of the most useful things in day to day game development is to know about those weird gotchas that you find in any complex tech. On top of that, you need to remember said gotchas the next time you encounter them. When developing cross platform games at a fast pace, I have solved problems and completely forgotten the solve the next time I bump into it six months later. Debug Diaries is my first attempt at trying to curb this. When I am faced with a weird problem, I am going to try to fix the problem while writing about it so that I can remember and hopefully, help you too. Here goes…

On doing the Amazon port of our soon to be released game, Thunder Jack’s Log Runner, I found that after adding the plugins to the port, the game too about 5 to 10 mins to load. I have seen this before when loading a lot of textures from resources but can be sure. The last thing I added before the problem was AdColony, which could have pushed me over the memory threshold. Time to pull it out and add some debug logs.

The first thing I did was to switch from my amazon branch to my google play branch to see if the problem was inherent or platform specific. For those who don’t know, most Android builds will work on Amazon devices because they are Android. You just have to watch out for the platform specific plugins.
Result: Same thing. So now, I am…




LA Unity User Group

LA Unity User Group January 2015

To all of you great folks out there that didn’t made it to the Unity 5 catch up in Los Angeles last month, it was a good one. Carl Callewaert and Mark Schoennagel from Unity came down for a chat and the wonderful folks at Microsoft hosted us in their snazzy Playa del Ray offices. Once again, a huge thank you to Mark and Carl for taking the time and to Microsoft for being so incredibly supportive. Bug sout out to Grant Viklund, who organizes the LA Unity User Group every month with out ever a word of complaint! If you get the chance, join the LAUUG Meet-Up and donate a couple of bucks to show your appreciation.

Carl spoke about Unity 5 and showed of the latest build. He showed how easy it was to use Unity’s new PBR lighting system just by placing and manipulating light and reflection probes. He showed how easy it was to create day/night cycles by blending between environment maps and how well the lighting system reacted. For those of you that might not know, PBR stands for Physically Based Rendering and uses a unified lighting approach to rendering. A standard set of physical properties are applied to all objects in the scene and a highly optimized shader stack does all the work. It relies heavily on reflection maps because its based on the principal that every object is reflective, just in varying…