- Home /
Question by
LunaTrap · Dec 05, 2015 at 05:29 PM ·
assetnullreferenceexceptionreferenceexceptionassetdatabase
Why AssetDatabase.LoadAssetAtPath does not trows exception?
why it does not trows exception if what is returned is null? i mean, i think it would be useful to tell me if the asset is not found, i wrote my own way of doing it, im a very noob girl to C# and Unity, have been learning for 1 year, i know i need a lot to learn and im sure the Unity engineers did it for a reason, but what do you guys think? im doing something bad? any idea to do this in a better way?
public static Object GetAssetAtPath(string path)
{
StringBuilder sb = new StringBuilder();
Object result = AssetDatabase.LoadAssetAtPath<Object>(path);
if(result == null)
{
sb.AppendFormat("Asset not found at path : \"{0}\"", path);
Debug.LogError(sb);
}
sb = null;
return result;
}
Comment
Your answer
Follow this Question
Related Questions
Need Help With a NullReference Exception 2 Answers
NullReferenceException Error 6 Answers
Custom assets give Missing (Mono Script) 0 Answers
Load an asset right as it is imported? 0 Answers
How do I import assets from the Asset Store while offline? 2 Answers