
Now save the script and let’s test if it works. So by setting the order to 51 will put your new asset in the second grouping of the Asset Menu. But keep in mind that unity separates assets into sub-groups by factors of 50. order: The order of the asset within the Asset Menu.menuName: The name of the asset as it appears in the Asset Menu.fileName: The default name of the asset when is created.That is why I’ve used the CreateAssetMenu attribute with the following parameters:

Let’s start with the first line: Before you can create an implementation of the ScriptableObjectExample class, you can add the ScriptableObject to the Asset Menu, this will make the creation of the Scriptable Object much easier. Public class ScriptableObjectExample : ScriptableObject Now fill the script with some basic variables and to make the creation of the ScriptableObject even simpler, we are going to use the CreateAssetMenu attribute, so we can easily create a ScriptableObject in a few clicks from the Unity editor. Instead, the ScriptableObject is treated like any other asset that you create using the unity editor window.Īnd that is one of the biggest advantages of the scriptable objects, they are assets that you can create/change and hook into Gameobjects to make everything highly decoupled and customizable.īut don’t worry, you’ll see some clear examples later. What are we doing here is very simple, we are telling Unity that we want to use the features of the ScriptableObject, as it would be with a MonoBehaviour.īut the difference is that you won’t use this script as a normal GameObject in the scene. Here is a very simple example: public class ScriptableObjectExample : ScriptableObject To create a ScriptableObject, you simply need to make your class inherit from the Scriptableobject class. To better understand a Scriptableobject, let’s start by making one. Getting Started with the Unity Scriptableobject: Customize player/NPC behaviour without touching the code.ĭon’t worry, we will see some examples in this tutorial and I’ll assure you that when you will grasp the essence of the ScriptableObject you will be a much better and skilled game developer.Easy to swap data without writing a single line of code.Custom and designer-friendly enum values.

Organize your assets (audio, sprites, etc).Yes, a Scriptableobject is like the holy grail of Unity, once you grasp the power of it, you can use them in basically every situation, but here are some examples of the use of a ScriptableObject within Unity: When you make some changes to a scriptable object at run time, they are saved.Modular: Systems do not directly depend on each other.

SCRIPTABLE OBJECT ARCHITECTURE HOW TO
As a matter of fact, we at Gladio Games use them in every project that we make.īut don’t worry, we are going to see what they are, why we use them and how to use them. You will discover that the scriptable objects are one of the most important features in Unity and you must use them as much as you can. Hello my friend, so today you are going to learn about the most amazing, undiscovered, unused and underestimated feature of unity: The power of the Scritableobject.
