I’ve been trying to use this script to set some custom import settings on my imported audio:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class AudioCustomImportSteps : AssetPostprocessor
{
const float DefaultQualitySetting = 0.9f;
void OnPreprocessAudio()
{
var importer = assetImporter as AudioImporter;
AudioImporterSampleSettings aiss = importer.defaultSampleSettings;
aiss.loadType = AudioClipLoadType.Streaming;
aiss.quality = DefaultQualitySetting;
importer.defaultSampleSettings = aiss;
importer.preloadAudioData = false;
importer.loadInBackground = false;
Debug.Log( "AudioCustomImportSteps.OnPreprocessAudio(" + importer.name + ") - PRE!");
}
void OnPostprocessAudio(AudioClip clip)
{
Debug.Log( "AudioCustomImportSteps.OnPpstprocessAudio(" + clip.name + ") - POST!");
}
}
This works great… but it works TOO well: I want it to only work once on WAV files that it has never seen before. When this script is present, it forces the affected settings ALWAYS to their values, no choice in the matter, and I cannot override them manually.
I want the above import step to only run on fresh audio samples it has never seen before. Do I have to keep track of what a first-time-import is myself and put that list under source control as well? Do I have to look at the timeStamp field and see if it is “oh just now or so” and make a choice?
Is this run-only-once-per-asset thing possible with Unity custom asset importers?
Thanks,
Kurt