in object-oriented programming, the command pattern is a behavioral pattern that allows encapsulating the information needed to perform an action or trigger an event at a later time.

to realize this pattern I will use a small example with some cubes that will change color, in this case, I will…

The pattern of which I speak today is part of the tools against the waste of resources. I have already written some articles about it advising not to use too often the keyword “new” especially in methods that are called continuously.
The object pooling helps us to lighten the workload…

The Singleton is one of the most famous programming patterns, it is also used with Unity, it is a creative design pattern that aims to ensure that one and only one instance of a given class is created, and to provide a global access point to that instance.


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.

Speaking of optimization it seems appropriate to dwell on the difference between struct and class.

Let’s start with a small definition of both

A class is a user-defined model or prototype from which objects are created. A class combines fields and methods into a single unit.

A structure is a…

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.

When you are working on a very large game the optimization of the code and the use of certain calls over others can make a difference. In a game, this manifests itself initially as a drop in FPS and then comes to a complete stop.

To check where this happens…

An AssetBundle is content that is stored separately from a main game or application and loaded/downloaded at runtime. This helps minimize the impact on network and system resources, allowing customers to download and install only the parts they need. AssetBundles can also be used to update or add content post-release.

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.

Andrea Alicino

project manager by day, unity developer by night

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