Posts tagged as 'Code Samples'

Work
December 19, 2014  by  

When working on my 2D lighting system, I needed to create some shadows. Shadows for sprites can easily be created by skewing the sprite and drawing it in all black. How much you skew depends on the position in relation to the light source. I already had a lighting and shadow system working in XNA, and now I just needed to get it working in Unity.

My first thought was to perfrom a skew from within Unity, in C#, like I did in XNA. As it turns out, you can’t (you can skew GUI elements, but not actual game objects). If you want to skew game objects, you need to skew the mesh itself, which I did actually get to work. However, this solution was a little ugly, and I’m not sure about the performance ramifications when recalculating every frame. So, I set off to find a more elegant solution.

Continue Reading…


Work
December 12, 2014  by  

At first glance, flashing text in a custom Unity editor window may sound like an annoyance, and it certainly can be if used inappropriately. But it can be a useful tool for catching a user’s attention if used responsibly. I use it in a few of my custom editors to alert the user to various situations:

  • Missing components. For example, my vertex painters won’t work if the selected game object does not contain a mesh component.
  • When you’re locking standard scene selection. For example, when my vertex painters are in “Paint Mode”, you cannot select scene objects when clicking in the scene. This can be confusing if you forget you are in “Paint Mode”, or you are using the tool for the first time.
  • Warning messages. “Changes cannot be undone” might be a good candidate.

Continue Reading…