, , ,

So, I have a new repo on GitHub. This is an Editor utility script that divides scene objects into static and non-static objects and writes them, along with concave Mesh Colliders, into a text file.

The reason I wrote this is that both of these are excellent ways to boost performance in Unity. Marking an object as static tells the physics engine that this object will never move, so it only needs to check the object’s position once. This lowers the amount of work the physics engine has to do, which frees up the CPU a bit.

Concave Mesh Colliders are another one. Mesh Colliders (and the 2D equivalent PolygonCollider) are based on the object’s mesh, so each vertex in the mesh is accounted for. These are the most accurate colliders, which comes at the expense of performance, but marking them as convex can offset this. This will result in the collider approximating the shape of the mesh, which is far quicker to calculate.

The initial release works out of the box on 5.3.4, but I may add some extras. For starters, the location and name of the file is hard-coded to Assets/staticObjects.txt. Secondly, the list is only valid for a single scene at the moment – if you run it in another scene, it overwrites the file. Neither is particularly difficult, but I’ll get around to it during the week.