So, I generate mesh assets using a third party tool, and then I save it to a .asset file. I can see the settings of the mesh in the inspector, but I can’t modify them like I would modify a .FBX. I also can’t set the IsReadable value on a mesh or use the ModelImporter class to modify that setting programmatically.
It does seem there’s another way to do it. The following works well, but at the end of the day, the only change it does to the file is the m_IsReadable value.
var loadedMesh = AssetDatabase.LoadAssetAtPath<Mesh>(path);
loadedMesh.UploadMeshData(true);
EditorUtility.SetDirty(loadedMesh);
AssetDatabase.SaveAssets();
I would also guess that you could probably use a SerializedObject with the m_IsReadable property, but I haven’t tested this.
I just checked, and sure enough, your method is to actually read the asset line by line and flip the line Kurt indicated above. I was expecting some sort of reflection mechanism, but this is an asset tool. Sad that this kind of thing is needed.
I saw Kurt’s method yesterday and having to take the model outside of Unity then open in a text editor was a pain with lots of models. So I decided to try to make a tool that would do it for me. First time making a tool and it has saved me some time. I had no idea it was even possible and spent so much time redoing Pro Builder modifications once to have it read write enabled.