Trigger Script on AudioListener

I’m trying to make a small function which resides on an object with an AudioListener so that I can print text at the location of the audio source. It’s so that I can print a cue when any sound that is picked up by the AudioListener is played - it would help deaf people play games.

Sounds like you want this text to be in 3D space, correct? Have a look at TextMesh. Also take a look at how to add 3D Text, which uses a TextMesh component. To enable the mesh by trigger, you could parent it under the collider which has a trigger attached, or add a trigger collider to the mesh itself, as well as your AudioSource. Either way, have a look at OnTriggerEnter.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
	void OnTriggerEnter(Collider c)
	{
	    if(c.gameObject.GetComponent<AudioSource>())
	    {
	        if(!c.audio.isPlaying)
	            c.audio.Play();
	    }
		
		else
		{
		    print ("No AudioSource Attached To Collider!");	
		}
	}
}