-
Notifications
You must be signed in to change notification settings - Fork 1
/
AudioImportProcessor.cs
32 lines (27 loc) · 1.24 KB
/
AudioImportProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UnityEngine;
using UnityEditor;
namespace III.AssetImportProcessor
{
/// <summary>
/// Configure Audio import settings on first import.
/// </summary>
public class AudioImportProcessor : AssetPostprocessor
{
private void OnPreprocessAudio()
{
// The variable "assetImporter" references the importer for the asset that is currently importing.
var importer = assetImporter as AudioImporter;
if (importer == null) return;
//If we already have a meta file for that asset it's a reimport and not a first import, so we don't want to apply the preset.
if (importer.importSettingsMissing)
{
AudioImporterSampleSettings sampleSettings = importer.defaultSampleSettings;
// Compression format should be dependant on the sound file being played
// sampleSettings.compressionFormat = AudioCompressionFormat.Vorbis;
sampleSettings.quality = 75f;
sampleSettings.sampleRateSetting = AudioSampleRateSetting.OptimizeSampleRate;
Debug.Log("Audio Import: override import settings for: " + importer.assetPath);
}
}
}
}