美文网首页
选设置模型导入设置中的Material Location( 批量

选设置模型导入设置中的Material Location( 批量

作者: Rayson | 来源:发表于2023-06-26 14:39 被阅读0次

    插件用法,放在Assets目录下, 然后在tool找到Batch Change Materials Location


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

    相关文章

      网友评论

          本文标题:选设置模型导入设置中的Material Location( 批量

          本文链接:https://www.haomeiwen.com/subject/fazwydtx.html