Using Editor script to get prefab reference from name

I’m trying to use an Editor script to take an array that includes the names of prefabs in a specific folder and then find each prefab & store a reference in a GameObject field (so I can more easily make a database of items by just pasting the name into a script array along with various attributes of the item rather than having to also manually drag the prefab for that item into a slot in the Inspector). I don’t need to instantiate the prefab, just look up its name in the folder and then store the result in a public GameObject variable in an array. Maybe I’m missing something obvious, but I couldn’t find a function that does this rather than instantiating the prefab.

1 Like

Ok, I found the answer and will post it here in case someone else needs this info: use AssetDatabase.LoadAssetAtPath

Object prefab = AssetDatabase.LoadAssetAtPath(“Assets/GameObject.prefab”, typeof(GameObject));

4 Likes