导入FBX模型白模?项目中模型资源太多,一个一个修改不仅费时费力还费眼。所以写了一个编辑器 一次性把Assets中所有FBX模型的Material Creation Mode替换成Standard。
贴上代码:
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
public class ModelImporterEditor : Editor
{
[MenuItem("Tools/ChangeFBXMaterialMode")]
static void ChangeFBXMaterialMode()
{
var dirs = Directory.GetDirectories("Assets");
ChangeLoop("Assets");
}
static void ChangeLoop(string dirPath)
{
var files = Directory.GetFiles(dirPath, "*FBX");
for (int i = 0; i < files.Length; i++)
{
Debug.Log(files[i]);
var importer = AssetImporter.GetAtPath(files[i]) as ModelImporter;
//Debug.Log(importer);
importer.materialImportMode = ModelImporterMaterialImportMode.ImportStandard;
importer.SaveAndReimport();
}
var dirs = Directory.GetDirectories(dirPath);
for (int i = 0; i < dirs.Length; i++)
{
ChangeLoop(dirs[i]);
}
}
}
大功告成!!!