AudioSource EXISTS but is not showing in the inspector?!?!

Hi all,

I have a monobehaviour script that uses the singleton design pattern, and the following line of code technically works (the audio source is indeed added and can play audio through it), but it does not show in the inspector.

	// attach an audio source and setup initial settings
	audioSource = singleton.transform.parent.gameObject.AddComponent(typeof(AudioSource)) as AudioSource;

My “audioSource” class member is also a public property (with private set)

Any ideas? It’s not that big a deal to me, but i’m curious to know why it’s not showing up.

Thanks

Mat

1 Answer

1

Ah, silly me!

I actually needed singleton.transform.gameObject (not singleton.transform.parent.gameObject - without the .parent).

Thanks

Mat