5 years later - my unity tips

This is my collection of tips for programmers that use Unity.

It's a lot, but all well considered, and I've cut a lot that I actually intended to include when I started writing. Check out my twitter channel for more.

Kind regards, Fredrik Ludvigsen

Hold your breath, here we go:

Always use GIT, Asset Serialization: Force Text and Version Control: Visible Meta Files

Store static configuration data (audio databases etc.) as many ScriptableObjects.

Here there is a lot of knowledge that comes together in a beautiful way.

Not convinced? Listen to this guy:

Enable alt-scroll to go through mesh renderers under the mouse cursor.

Here's a script that every Unity developer I know has fallen in love with. http://wiki.unity3d.com/index.php/SelectByMouseScroll

Don't rely on names of scenes.

Your colleagues are going to betray you. If they don't rename a scene, they're going to really, really tempt you to do it yourself.

Don't fight them, but refer directly scenes, like this. http://wiki.unity3d.com/index.php/SceneField

Don't use Time.deltaTime in Lerp

I'm talking about the following popular easing (don't do it):

pos = Vector3.Lerp(pos, target, Time.deltaTime / 50f);

The equation you're looking for is called exponential decay, and it's super nice. It works the same but is frame rate independent.

Details here.

ContextMenu is the quickest way to transform a set of ScriptableObjects.

Simply create your method, select the objects and select the context menu option.


Create your own async tasks

It's easier than you'd think.

Use lock free queues when working with threads

With a lock free queue, working with threads becomes a piece of cake.

Use one queue for input and one queue for output. Now your threads have an efficient way to fetch and deliver data, no more conflicts or race conditions.

A tidy lock free queue for Unity, here.

Make sure that all bugs that are spotted gets registered

This is easy to do with a plugin like Dungbeetle, and it's by far the best way to reduce the number of testing hours required for your game.

In my projects I actually rarely see a bug twice, and it's just because of how efficient the bug registration process and tracking is.

Follow my twitter channel

I write unity tips there. Infrequently, but with high quality. Worth scrolling through.