private static void HandleDir(string path) { var dirInfo = new DirectoryInfo(path); foreach (var dir in dirInfo.GetDirectories()) { HandleDir(dir.FullName); } foreach (var file in dirInfo.GetFiles()) { HandleFile(file.FullName); } }
private static void HandleFile(string path) { var info = new FileInfo(path); if (!AudioExtension.Contains(info.Extension)) return;
var audioImporter = AssetImporter.GetAtPath(TransformToRelevant(path)) as AudioImporter; if (audioImporter == null) { DebugUtil.Log($"audio importer not found for path: {path}"); return; }
var changed = false;
if (audioImporter.GetOverrideSampleSettings("android").GetHashCode() != audioImporter.defaultSampleSettings.GetHashCode()) { changed = true; audioImporter.ClearSampleSettingOverride("android"); }
if (audioImporter.GetOverrideSampleSettings("iOS").GetHashCode() != audioImporter.defaultSampleSettings.GetHashCode()) { changed = true; audioImporter.ClearSampleSettingOverride("iOS"); }
if (!audioImporter.forceToMono) { changed = true; audioImporter.forceToMono = true; }
if (audioImporter.loadInBackground) { changed = true; audioImporter.loadInBackground = false; }
if (audioImporter.ambisonic) { changed = true; audioImporter.ambisonic = false; }
if (!audioImporter.preloadAudioData) { changed = true; audioImporter.preloadAudioData = true; }
var defaultSettings = audioImporter.defaultSampleSettings; var settings = new AudioImporterSampleSettings(); if (info.Length < 204800) { settings.loadType = AudioClipLoadType.DecompressOnLoad; if (defaultSettings.loadType != AudioClipLoadType.DecompressOnLoad) changed = true;
settings.compressionFormat = AudioCompressionFormat.Vorbis; if (defaultSettings.compressionFormat != AudioCompressionFormat.Vorbis) changed = true;