选设置模型导入设置中的Material Location( 批量
2023-06-26 本文已影响0人
Rayson
插件用法,放在Assets目录下, 然后在tool找到Batch Change Materials Location
![](https://img.haomeiwen.com/i11652549/760c4055087dd780.png)
using UnityEngine;
using UnityEditor;
namespace SK.Framework
{
public class ModelImportSettings : EditorWindow
{
private ModelImporterMaterialLocation location;
[MenuItem("SKFramework/Tools/Model Import Settings")]
private static void Open()
{
GetWindow<ModelImportSettings>("Model Import Settings").Show();
}
private void OnGUI()
{
GUILayout.BeginHorizontal();
{
GUILayout.Label("Location");
location = (ModelImporterMaterialLocation)EditorGUILayout.EnumPopup(location);
}
GUILayout.EndHorizontal();
if (Selection.gameObjects.Length == 0) return;
GUILayout.FlexibleSpace();
if (GUILayout.Button("Apply"))
{
for (int i = 0; i < Selection.gameObjects.Length; i++)
{
var obj = Selection.gameObjects[i];
string path = AssetDatabase.GetAssetPath(obj);
ModelImporter importer = AssetImporter.GetAtPath(path) as ModelImporter;
if (importer != null)
{
importer.materialLocation = location;
}
}
}
}
private void OnSelectionChange()
{
Repaint();
}
}
}