private void ProcessAllModel(ModelImporter templateImporter)
        {
            string folderPath = Path.GetDirectoryName(templateImporter.assetPath);

            string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Model, folderPath);
            for (int i = 0; i < findAssets.Length; i++)
            {
                string assetPath = findAssets[i];
                if (Path.GetFileName(assetPath) == Path.GetFileName(templateImporter.assetPath))
                {
                    continue;
                }
                AssetDatabase.ImportAsset(assetPath);
            }
        }
示例#2
0
        /// <summary>
        /// 清理无用的材质球属性
        /// </summary>
        public static void ClearMaterialUnusedProperty()
        {
            // 获取所有的打包路径
            List <string> collectDirectorys = AssetBundleCollectorSettingData.GetAllCollectDirectory();

            if (collectDirectorys.Count == 0)
            {
                throw new Exception("打包路径列表不能为空");
            }

            // 获取所有资源列表
            int checkCount   = 0;
            int removedCount = 0;

            string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Material, collectDirectorys.ToArray());
            foreach (string assetPath in findAssets)
            {
                Material mat     = AssetDatabase.LoadAssetAtPath <Material>(assetPath);
                bool     removed = EditorTools.ClearMaterialUnusedProperty(mat);
                if (removed)
                {
                    removedCount++;
                    Debug.LogWarning($"材质球已被处理:{assetPath}");
                }
                EditorTools.DisplayProgressBar("清理无用的材质球属性", ++checkCount, findAssets.Length);
            }
            EditorTools.ClearProgressBar();

            if (removedCount == 0)
            {
                Debug.Log($"没有发现冗余的材质球属性");
            }
            else
            {
                AssetDatabase.SaveAssets();
            }
        }