- Home /
Update prefabs after using AssetDatabase.SaveAssets / AssetDatabase.CreateAsset ?
I am using the following to dynamically create mesh assets for my game:
AssetDatabase.CreateAsset(meshToSave, fullPath);
AssetDatabase.SaveAssets();
Basically we have a lot of tiles that make up the levels in our game that will never move in the final game so we use a tool to bake them all into a single mesh, then use the above to save that generated mesh as an asset so it doesn't get lost when we switch scenes or spawn the object from a prefab etc.
Problem is, if we later need to update the mesh, it breaks any prefabs that were using that mesh. What I expect to happen was for those prefabs to use the new mesh just like it would if we changed a child prefab or summited a new version of an fbx mesh. The file has the exact same name. Instead all prefabs show the MeshFilter mesh field as "Missing (mesh)" as if the asset was deleted.
Is there some step I need to do to preserve the link between the MeshFilters and the generated mesh asset?
Wondering if CreateAsset() is nuking the meta file or something...
Your answer
