AudioClip is null in OnPostProcessAudio( AudioClip newClip), how to fix/get name?

Problem solved: I don’t own the pro version of Unity3d and thus cannot access the asset pipeline via script, as per the License Comparison of the editor:

I’ve created an editor script that creates a prefab for an AudioClip whenever it is imported (or reimported).

The problem I have is that in the OnPostProcessAudio() function call I need to access the name of the recently added/edited AudioClip but the name variable of the AudioClip is always null/empty.

Here’s the code:

using UnityEngine;
using System.Collections;
using UnityEditor;

public class AudioPrefabGenerater : AssetPostprocessor
	public void OnPostprocessAudio (AudioClip newClip)
		//This gets the audio prefab directory 
		string audioPrefabDirPath = AudioManager.GetAudioPrefabDirFullPath();
		//This creates the file name from the newClip's name and its extension (prefab)
		string fileName =".prefab";
		//This creates an empty prefab in the audioPrefab directory
		Object emptyPrefab = PrefabUtility.CreateEmptyPrefab(audioPrefabDirPath+fileName);
		//This creates a new GameObject with newClip's name
		GameObject newAudioGo = new GameObject(;
		//Add the AudioSource component and set the clip to be newClip
		newAudioGo.AddComponent<AudioSource>().clip = newClip;
		PrefabUtility.ReplacePrefab(newAudioGo.gameObject, emptyPrefab, ReplacePrefabOptions.ConnectToPrefab);

I don’t know why it’s empty, but you can try using AssetPostprocessor.assetPath instead.

Use This:

    void OnPostprocessAudio(AudioClip nullClip)
    		var audioClip = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AudioClip)) as AudioClip;
    		//use audioClip instead of nullClip