var somePrefab : GameObject = AssetDatabase.LoadAssetAtPath("Assets/SomeFolder/thePrefab.prefab", typeof(GameObject));
This always returns null for me…I’ve been digging around the 'net and trying all sorts of different methods, but nothing works yet. Please help? So frustrated!
Yep, everything else works fine. Have all sorts of lovely things working (lol, first time doing editor scripting, loving the flexibility), but this one thing will not budge.
Just a thought, don’t know if this will work… but in an editor script I wrote I use that function. For the second parameter (looking through my code) I simply have “GameObject,” no typeof.
Oh wait, I already tried it with no “typeof”, no luck Errg. I just don’t see why this isn’t working. It’s the final piece of a really helpful script I’ve got going, but no joy
Met the same problem. It came up when I did a copy of asset folder with AssetDatabase.ImportAsset(newAssetPath);. Strangely that the assets in the newpath were not contained in the AssetDatabase! (Thanks to roberto_sc’s advice of checking the AssetDatabase!)
So I just fixed it by:
AssetDatabase.ImportAsset(newpath);
var asset = AssetDatabase.LoadAssetAtPath(newpath, typeof(xxx));