A
A
Almost2020-10-20 13:38:25
Unity
Almost, 2020-10-20 13:38:25

How to call your function when creating a ScriptableObject through the context menu?

Here is the scriptable object:

[CreateAssetMenu(fileName = "NewLevel", menuName = "Game/Levels/Level", order = 0)]
public class LevelContext : ScriptableObject
{
    public int id;
    public int enemyCount;
    public List<LevelContext> previousLevels;
    public List<LevelContext> nextLevels;
}


Is it possible to call some function from another class, or from this one when creating this object through the context menu?

5f8ebdff728e2668642846.png

This is necessary so that the id to ScriptableObject is automatically assigned when this function is called, based on the existing objects in the project of this class.

There is an option to make a custom editor, where when a button is pressed, an object will be created and the necessary id will be assigned to it, but this greatly complicates everything, I would like to try to find a simpler solution.

Google didn't help.

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question