Unity报错:This MeshCollider requires the mesh to be marked.....

运行或者打包时候报错:This MeshCollider requires the mesh to be marked as readable in order to be usable with the given transform.

解决方法:开启Meshes的读写

可以写一个批量处理的脚本:

using UnityEngine;
using UnityEditor;
using System.IO;

public class FixModel
{
    [MenuItem("Tools/FixModel")]
    static void Fix()
    {
        var fs = Directory.GetFiles(Application.dataPath, "*.FBX", SearchOption.AllDirectories);
        foreach(var f in fs)
        {
            var path = f.Replace(Application.dataPath, "Assets");
            var imp = AssetImporter.GetAtPath(path) as ModelImporter;
            if(null == imp)
            {
                Debug.LogError(Path.GetFileName(f) + " is not a Model");
            }
            else
            {
                if(!imp.isReadable)
                {
                    imp.isReadable = true;
                    Debug.Log("fix " + path);
                    imp.SaveAndReimport();
                }
            }
        }

        AssetDatabase.Refresh();
    }
}
发布了127 篇原创文章 · 获赞 278 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/LLLLL__/article/details/103799786