Hey, right now I’m using AssetDatabase.LoadAssetAtPath(), however whenever I want to load a SO-asset outside of an OnEnable() method, I get an error.
Ideally I need a static reference to my SO’s to create proper helper classes, because the way it is right now, I have to create these references very hacky through instantiating a helper class object in OnEnable() of each editor that uses it, which is a proper nuisance, as I would like to have the helper classes be static.
Is it possible for you to just have it assign in a public variable via the inspector?
I guess that would be another hacky way, however I am writing my editors with portability in mind, as I plan to use them in multiple projects and would therefore like them to be drag-and-drop-able without having to create scene objcts, since they are solely database-oriented.
yeah, I had this issue and couldn’t find a solution. I think you can’t do it on enable, but I may be wrong. If you don’t use them on enable (you probably shouldn’t anyway) you could try to use them a bit like this to only loaded if it’s null, and leave it from enable:
public Databases_Ref Db { get { if (_db == null) { _db = (Resources.Load("Databases") as GameObject).GetComponent<Databases_Ref>(); } return _db; } }