Hi, sorry if this is a weird question, but does anyone know of a way to either directly access ScriptableObject assets at editor time (i.e., not through an inspector-set field), or to force all ScriptableObject instances to be created when Unity loads? I'm trying to create an editor that needs a list of all ScriptableObject instances of a given type, but I've found that in editor mode, Unity only creates those instances as-needed.
#Loading and Accessing ScriptableObject instances without Inspector
1 messages · Page 1 of 1 (latest)
The way I've been doing it thus far was to have the instances register themselves in a static list on instantiation, but the list can be referenced before all of the instances have been created and registered.
It isn't exactly clear what you are doing. You can use AssetDatabase.FindAssets("t:YouSOType") to find all SO assets of a given type.
You can use Resources.FindAllObjectsOfType<YourSOType>(); to find all SOs that are loaded in memory ether in the editor or during play.
I can send the relevant code
Ingredient.cs
https://paste.ofcode.org/34u44T8KskrCjqfCbEGx79K
Are you trying to get he list for runtime use or for use in the editor?
Reference in custom editor
https://paste.ofcode.org/QeDsTQQfFbebTcJx86Q8HE
use in editor
You want to use the first method I mentioned then
You can google something like "Unity editor how to find all assets of type" and it should give you what you need
ah, so i suppose then i would use this in conjunction with AssetDatabase.LoadAssetAtPath
or wait
You would actually need to first use AssetDatabase.GetAssetPathFromGUID but yeah
gotcha
(or whatever the method is called, I can't remember exactly)
a lil roundabout but it seems reasonable
i suppose my use-case isn't a particularly common one
It isn't that uncommon either
oh huh
I've done it multiple times
i'll try this out then