What is Unity ScriptableObject?

What is Unity ScriptableObject?

What is Unity Scriptable Object?

I can say that a Scriptable Object is a data storage script created by Unity. You can edit, save, and delete the data you store inside it either through the Editor or from within the game.
You can save large data within your project as a ScriptableObject and then easily access and edit this data.

A Scriptable Object is a data container that you can use to save large amounts of data, independent of class instances. - Unity Documentation

If we need to translate it into Turkish 

Scriptable Object is a data container (data repository) where you can store large amounts of data independently of classes. - Unity Documentation

Now that we've given the basic information about Scriptable Objects, let's look at how to use them. 

Usage of Scriptable Object

First, we need to create a script and make it inherit from the ScriptableObject class. Let's illustrate these with code.

using UnityEngine;

// menuName = The name that your Scriptable Object will appear as in the menu. If you want to categorize, you can use the "category/scriptable object name" method.
// fileName = The name that the Scriptable Object will have when created.
// order = The order it will appear in the menu.
[CreateAssetMenu(menuName = "UrhobA/Scriptable Object Menu Name", fileName = "Created Scriptable Object Name", order = 0)]
public class UrhobASO : ScriptableObject
{
    // Variable declarations
    // We declare them as public here so that they can be used by other scripts as well.
    public string stringValue;
    public int intValue;
    public float floatValue;


    private void Awake()
    {
        Debug.Log("As in Monobehaviour, the awake function is also present in scriptable objects.");
        Debug.Log("Awake only works in the editor");
    }

    private void OnEnable()
    {
        Debug.Log("The OnEnable function is also present in scriptable objects.");
        Debug.Log("OnEnable works both in the editor and at run time.");
    }

    private void OnDisable()
    {
        Debug.Log("The OnDisable function is also present in scriptable objects.");

    }
}

After writing the code for our Scriptable Object, you can now right-click in the "folder" part of your folders and create actual objects for your data from the object we created.

Creating Scriptable Object

You can enter and edit values for the Scriptable Object you created from the Inspector panel.

Scriptable Objects Inspector

Later, you can drag and drop this object you have created to another object where you want to use it. You can access this object from another script as if you were accessing a normal class.