kenlem
November 10, 2008, 4:22am
1
The audio samples I find declare the audio clip but I don’t see where this actual clip is being
assigned.
// Plays the clip at position
var clip : AudioClip;
AudioSource.PlayClipAtPoint(clip, Vector3 (5, 1, 2));
Shouldn’t there be a line somewhere like
clip = findTheSoundClipWithName("SomeSound");
Thanks.
kenlem
November 10, 2008, 12:13pm
3
Thanks. That’s what I needed.
Boy, the more I work with Unity, the more I love it.
I would like to do this without the inspector. Is it possible?
/// Play build sound when placed by player:
_audio_build_clip = Resources.Load("menu_klik2", AudioClip);
if (audio_build_clip != null)
{
audio.clip = audio_build_clip;
audio.Play();
}
The sound file needs to be placed in a resource folder though.
Hey thanks Almar. I wanted to know how to do this a couple weeks ago, but couldn’t figure it out in a speedy manner.
I saved it for future reference.
Thanks!!! Now I have the code structure alternatives I was hoping for. I realized, however, that it’s mostly a better alternative to use the inspector after all… at least for my project.