Make a Scriptable Object hold another SO by default

I have two classes A and B that derive from scriptable object.

Currently, class A has a public field of type B. When creating a new A through the asset menu, I have to drag in any B to this field.
However, I want a specific B to be automatically part of A, so without me having to assign it for every A.

My first idea would be to use OnEnable and search for the asset in some way and set the field if it is null, but im not sure if this is smart or even possible.

Any ideas? Thank you for your time!

In the editor scripts you may use AssetDatabase to search through assets, check this Unity - Scripting API: AssetDatabase

1 Like

You can also use OnValidate and get a reference to it directly from code using like Resources.Load or AssetDatabase.FindAsset (not sure on its use)

1 Like