Loading Mesh assets for MeshFilter assignment

Hi all,

I am having trouble using “AssetDatabase.LoadAssetAtPath” and even using “Resources.Load” to load a .mesh file in the editor hierarchy and assign it to a prefab’s MeshFilter.

I am doing this as an editor function, not application runtime. I am trying to use the following code:

Mesh referenceMesh = (Mesh)AssetDatabase.LoadAssetAtPath(newMeshRefPath, typeof(Mesh)) as Mesh;

The path is correct, I have triple checked it in debug and it is returning null. Can .mesh files be loaded like this? Does anyone have an alternative if not?

Thanks!

For anybody else that might be having this trouble…

I was perusing the Unity documentation for other reasons a few days ago and noticed a mention of Unity’s ‘supported file extensions’ and it got me to thinking. I believe .mesh is not actually a supported extension in Unity.

If you are saving meshes that you want to assign later, rather than ‘.mesh’, use ‘.asset’ and it will solve the issues I describe above.