Unity tips / personal guidelines [work in progress]

I have started with Unity development. This page sumarizes some things I have used and I maybe will use them again in another project. This page is to remember them and found them easily, there is no pattern or order in presented things.

Some useful tutorials

First tutorial project - pdf (Based on video tutorial from Unity3D: source)



Combinations of collision responses based on body / collider settings


SphereCast moves a Sphere volume down the direction and distance of a ray and detects what it bumps into (source).

Force modes

Copied from: source.



Execution order of Unity event methods - also gives list of those methods and what they do


World space canvas

Use RectTransform to set Width / Height in pixels. This is NOT the real size we want to see. If we want our canvas to be 40x20, use 400x200 and set Scale to be (0.1, 0.1, 0.1). If 40x20 is set directly without use of scale, children elements such Fonts, Images etc. will be too small or result in smudged textures. I don't know why, but this was the only way it worked correctly for me (with scale).

World space GUI rendered always on top

To render world space based GUI on top of everything, use two cameras.

Otherwise, first and second camera have the same settings. That means, if render to texture is use, both cameras must have the same texture attached. In scene hierarchy, second camera must be after the first one. Other solutions / sources - link (solution from debeani is described above).


Final build

In my code, I have used

. Those shaders must be in Resources folder!!! If they are not, it will work in editor, but not in build (source).

Disable frame lock

Edit -> Project Settings -> Quality: The default quality profile is "Good", so expand "Good", and set "VSYNC Count" to "Don't Sync. Also, sometimes its needed to put Application.targetFrameRate = -1; somewhere in a script. (source).

Martin Prantl 2015