Today I focus on some optimizations related to the UI
Let’s talk about the canvas, only the main element of the interfaces, it often happens to see only one canvas inside all the types of elements that represent the game UI. This does not help from the point of view of resources because every time a change occurs in the UI the whole canvas is reinitialized to update. A solution to consider could be to split the UI and create a more dedicated canvas.
A second trick concerns the components within the canvas, many UI objects have the ability to be selected, not just buttons, and for this, they have a component that allows them to receive a raycast. The solution to avoid overlapping is to check the single components and deactivate the “Raycast Target” flag.
The profiler gives us the tools to find where we are wasting resources, once identified we must understand how to optimize it.
We have already said that the print commands on the console use a lot of resources, especially when they are constantly called in the Update method. We have to pay attention to what we write in the Update. Also in the Coroutines, we should be careful because they are always running.
In the Coroutines, we can optimize the code by removing the keyword ‘new’ and creating beforehand the variables that we need. The simple step of declaring the variables and initializing them in the Start method allows us to lighten the workload.
The app development course is also completed. This course was one of the most difficult because it took me far outside my comfort zone.
Using AWS was really very interesting, creating AssetBundle a completely new discovery.
I’m more and more satisfied with the choice I made several months ago, I’ve really found the desire to get back into gaming. The next course is about optimization and what we could call best practices for the development of a video game.