Implementing Command Design Pattern in Unity

Let’s get back to the design patterns for Unity!
Today let’s introduce Command Design Pattern! This design pattern is famous for its encapsulation of requests, which can be useful for many applications and often is used for handling user input, but it’s not the only use case.

Command Design Pattern

The idea behind this design pattern is to move requests to the objects which could be collected and be executed in the queue. You can think about them like Actions or Events but represented as objects.

Continue reading “Implementing Command Design Pattern in Unity”

Extension Methods in Unity

Today we are going to learn something entirely new! Extension Methods!
Sometimes as you are developing a game, you have this idea in your mind that you wish you could add some more functionality to Unity Components.
With extension methods, you can do that! ?

But how do they work?

Extension methods are mostly used when you have existing classes, but you can’t edit them, just like in Unity. With them, we can add more functions that will make our lives easier.

Continue reading “Extension Methods in Unity”

Custom Window in Unity

Continuing subject of building tools in Unity, today we are going to build custom window in Unity Editor. If you’ve missed the last post about building a custom component inspector, I would recommend checking it first. ?

To build custom tools in Unity, we have to prepare a custom window in Editor. We can achieve that by using the EditorWindow class.

Like with a custom inspector for components, and here we have to use the old GUI system. There is just one difference between building inspector and window. In inspector, we were using OnInspectorGUI() method and we could use DrawDefaultInspector() to draw component’s properties. In the window, we don’t have such luxury, but we have OnGUI() which works in the same way.

Continue reading “Custom Window in Unity”

Custom Inspector in Unity

Building a big project within a small team often requires building some shortcuts. One of them could be a custom inspector. Let’s find out how to make them in Unity!

Building a custom inspector is easy in Unity. You need to follow this 200-step instru… No, just kidding. ?

But in actual fact, it’s very easy!

The only thing that you need to do is to create an editor script for the component that you want to customize. And besides that, you also need to understand how Unity’s old GUI system works.

Continue reading “Custom Inspector in Unity”

Basics of Scriptable Objects in Unity

Today we will tackle something easier as the subject of Scriptable Objects in Unity is fairly straightforward. What is so cool about them is that you can throw so much different thing in them!

What Scriptable Object is?

According to the definition provided by Unity, Scriptable Object is a data container that let you save a lot of data and reduce memory usage. You can create them from code or by making new instances in the project view.

Creating Scriptable Object

Thanks to that you can easily create a lot of different representation of data, for example, inventory items, skills, game modes and more.

Using Scriptable Objects as items

The sky is the limit as they say ?

Continue reading “Basics of Scriptable Objects in Unity”