Some ways you can optimize your unity project

Understanding how Unity UI works

First of all, we are going to explain some small technical details about the operation of the UI rendering in Unity, with these concepts a little clearer it will be more obvious to understand the practical advice that we will present later.

Practical tips to optimize our UI

As we have already seen, each change that is made to a canvas implies that the entire canvas is recalculated, so a good practice is to divide the UI into different canvas, the idea would be to group in the same canvas the elements that are updated at the same time, such as the energy of the attack that goes down every time we hit and the experience points that we gain by eliminating enemies. An interesting point to keep in mind is that we can create a canvas within another canvas. If the child canvas is modified it will not affect the entire parent canvas, since each canvas is isolated, so the elements of the child canvas should simply be recalculated, but in no case those of the parent.

Layers & Collision Matrix

Any object created in Unity, if not configured, will have the default Layer assigned (Default). This means that, in the case of associating a collider to the object, it will collide with the entire environment since, by default, this Layer is configured like this. However, in many cases, we won’t need our objects to collide with every other object in our scene. For this, Unity offers us the “Layer Collision Matrix”, which is nothing more than a matrix of layers where we will configure what each of the layers can and cannot collide with.

Edit > Project Settings > Physics -> Layer Collision Matrix

Avoid calls to Find … () methods

Level of Detail (LOD)

Level of Detail (better known as LOD) is another very common rendering optimization technique that is based on the following: objects close to the player are rendered with the maximum detail (using Maya and detailed textures), while objects far away pass to have a much less detailed rendering.

Using the “Profiler”

The Unity editor offers us the “Profiler” tool that is in charge of giving us, in real-time, all kinds of information about the performance of our game. For example, if we have problems regarding memory use, through this window we will be able to know which element (or elements) of our project is causing it.

Window -> Profiler

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alexander Urrego

Alexander Urrego

Systems Engineer with a huge experience working on IT infrastructure projects and passionate about software development, AR/VR, Big Data, and Machine Learning.