Tag: 2D

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 Text

Unity Text Solutions

So we all know that text in Unity used to be a right pain in the rear. At least doing it without a gazillion draw calls using OnGUI. Things have changed slightly with all the current 2D solutions and Unity’s text mesh but I feel like each one fails at something, even be it a small thing. Through investigating a “read to me” system for my wife’s new game, Notespace Beat, I have taken a good hard look at some of the best solutions out there and am giving you a quick run down. Before we get into it, I had a very specific set of text requirements that I needed to satisfy. I need to be able to change size easily, change the style of the font (bold, italic), change the line spacing and pretty much everything you can do with in a text area in photoshop. It needs to be light and I need to get to the positional data of the text so I can find out if a user tapped a word.

First up, Unity Text Mesh.
I have never really played with Text Mesh before this project because I was always under the assumption that it would not work with my current work flow and 2D solutions. I was wrong about that and there are a lot of things to write home about here. First off, the dynamic font generation is pretty dope. Not having to make new font maps every time I change my font or its…