AssetDatabase.LoadAssetAtPath Not finding assets
Hello,
I'm using AssetDatabase.LoadAssetAtPath and it works, but only for my Scripableobjects. I've checked and double-checked everything, but it just won't work on my other assets, see code below.
Working with scriptable objects:
private void PopulateEffectGroups()
{
List<EffectsGroup> data = new List<EffectsGroup>();
string[] guids1 = AssetDatabase.FindAssets("t:EffectsGroup", new[] { "Assets/_GAME/Scriptable Objects/Effect Settings" });
Debug.Log(guids1.Length + " Assets");
foreach (string guid1 in guids1)
{
//Debug.Log(AssetDatabase.GUIDToAssetPath(guid1));
var path = AssetDatabase.GUIDToAssetPath(guid1);
var effect = (EffectsGroup)AssetDatabase.LoadAssetAtPath(path, typeof(EffectsGroup));
data.Add(effect);
Debug.Log($"Loaded Asset: {effect.name}");
}
this.effectsGroups = data.ToArray();
}
And this is with my Projectile scripts, which doesn't work:
private void PopulateProjectiles()
{
List<DamageProjectile> data = new List<DamageProjectile>();
string[] guids1 = AssetDatabase.FindAssets("t:DamageProjectile", new[] { "Assets/_GAME/Prefabs/Projectiles" });
Debug.Log(guids1.Length + " Assets");
foreach (string guid1 in guids1)
{
//Debug.Log(AssetDatabase.GUIDToAssetPath(guid1));
var path = AssetDatabase.GUIDToAssetPath(guid1);
var effect = (DamageProjectile)AssetDatabase.LoadAssetAtPath(path, typeof(DamageProjectile));
data.Add(effect);
Debug.Log($"Loaded Asset: {effect.name}");
}
this.projectiles = data.ToArray();
}
I've tried LoadMainAsset, but that also doesn't work. I've checked the path and it's the correct path.
The DamageProjectile, is a script attached to a Prefab, but it's also inherited from another type. Even scripts that don't inherit aren't found.
Thanks for any help!
Your answer
![](https://koobas.hobune.stream/wayback/20220613042953im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ScriptableObject not saving to Asset properly 0 Answers
How can I get a sub asset? 1 Answer
Slow unity things 0 Answers
Why unity tries to save clean assets? 1 Answer
because my game does not access my Scriptable Object 0 Answers