Unity解决:报错requires the mesh to be marked as readable in order to be usable with the given transform

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

解决方法:开启Meshes的读写

Unity解决:报错requires the mesh to be marked as readable in order to be usable with the given transform_第1张图片

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

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();
    }
}

你可能感兴趣的:(C#,Unity,unity,游戏引擎)