Unity 编辑器开发实战【Model Importer】- 如何多选设置模型导入设置中的Material Location( 批量解压 模型格式)

 批量解压模型格式!

尊重原著:(1条消息) Unity 编辑器开发实战【Model Importer】- 如何多选设置模型导入设置中的Material Location_unity modelimporter_CoderZ1010的博客-CSDN博客

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

猜你喜欢

转载自blog.csdn.net/qq_37524903/article/details/130327444