The blog moved

I moved this blog to jakobknudsen.com.

Value pairs in the Unity inspector

Some times I chance upon some little thing related to working in Unity, that just instantly changes a part of my workflow. It’s not long ago, that I learned Shift-Delete removes the highlighted value from a public array in the inspector and rearranges and resizes the array accordingly. Up until then I had just been resizing the list and manually rearranging it, which was a pain. I’m sure many people knew this and took it as the most obvious and trivial little feature, but not knowing about it before has cost me so many hours of tedious work, that it was huge for me when I found out.

I think I have just stumbled on another thing like this: Serializable values show up seamlessly in the inspector. If you already knew this, this post holds no surprises for you, but it has already changed how I design my Unity scripts, and in this post I’ll show how.

Read More…

iOS style camera-dragging in Unity

The most common method of camera-control in an RTS is responding to the mouse moving to the edge of the screen and keyboard input, but of course that’s not the only way to do it. Some games, like Crusader Kings II, lets you drag your mouse across the screen to move the camera as if you are dragging the world below you. It’s also how you navigate stuff like maps and large documents in iOS. In this post I explain how you can do this in Unity.

Camera being dragged over hex-tiles in Unity.

Camera being dragged over hex-tiles in Unity.

Read More…

Altitude Fog shader for Unity

The island on the left side cuts off in a rather ugly fashion. The one on the right seems to fade into the depths. That is the look we are after.

The island on the left side cuts off in a rather ugly fashion. The one on the right seems to fade into the depths. That is the look we are after.


When you submerge an object in water you expect it to become more and more obscured as it sinks further into the depths. As far as I can see, this is usually accomplished in Unity3D with a fullscreen image-effect like the global fog standard asset. But that only works in the pro-version of Unity, and I want something that works in the free version. This post shows my solution.

Read More…

Transparency and sorting in Unity

Transparency often presents a problem when I’m working in Unity3D. The methods used for rendering objects in the right order doesn’t work well with transparency, so I often need a work-around specifically crafted to whatever I am trying to achieve. This isn’t some wierd quirk in Unity though, it’s just a problem with the way realtime rendering is done. In this post I show a couple of problems I have encountered, explain why they happen and what can be done to work around the issue.

Read More…