private void GetDirSetting(string relPath) { if (!string.IsNullOrEmpty(relPath)) { string path = AMTool.GetAbsPath(relPath); if (!Directory.Exists(path)) { return; } Dictionary <string, TextureSetting> dict = new Dictionary <string, TextureSetting>(); TextureSetting root = TextureSettings.Find(t => t.RelPath.Equals(relPath)); if (root == null) { var setting = new TextureSetting(); setting.RelPath = relPath; dict.Add(path, setting); TextureSettings.Add(dict[path]); } else { AMTool.GetCurrentSetting(root, dict); } AMTool.LoadDirSetting(path, dict); } }
//-------特殊导入方案 /// <summary> /// 检查当前设置是否适合包含的资源 /// </summary> public void CheckSettingIllegel() { Dictionary <string, TextureSetting> dict = AMTool.GetDictionary(TextureSettings); float count = 0; StringBuilder nullBuilder = new StringBuilder(); StringBuilder illegelBuilder = new StringBuilder(); foreach (var item in dict) { EditorUtility.DisplayProgressBar("检查", item.Value.RelPath, count++ / dict.Count); if (item.Value.Children.Count > 0 || !item.Value.IsActive) { continue; } bool hasAlpha = item.Value.AndroidImporterFormat == TextureImporterFormat.ETC2_RGBA8 || item.Value.IOSImporterFormat == TextureImporterFormat.PVRTC_RGBA4; string[] fs = Directory.GetFiles(AMTool.GetAbsPath(item.Value.RelPath), "*.*", SearchOption.TopDirectoryOnly); foreach (var f in fs) { if (Path.GetExtension(f).Equals(".meta")) { continue; } string relPath = AMTool.GetUnityPath(f); TextureImporter importer = AssetImporter.GetAtPath(relPath) as TextureImporter; if (importer == null) { nullBuilder.AppendLine(relPath); continue; } if (importer.DoesSourceTextureHaveAlpha() == hasAlpha) { continue; } illegelBuilder.AppendLine(relPath); } } Debug.LogError(illegelBuilder.ToString()); Debug.LogError("---------------TextureImporter-NULL----------------"); Debug.LogError(nullBuilder.ToString()); EditorUtility.ClearProgressBar(); }