PowenKo, Unity Tutorial 130 , Aduio, AudioClip play

August 31, 2011   ·   0 Comments

using UnityEngine;
using System.Collections;




public class audiosample : MonoBehaviour {
public AudioClip theClip;
	
AudioSource PlayAudioClip(AudioClip clip, Vector3 position, float volume) {
GameObject go = new GameObject("One shot audio");
go.transform.position = position;
AudioSource source = go.AddComponent<AudioSource>();
source.clip = clip;
source.volume = volume;
source.Play();
Destroy(go, clip.length);
return source;
}
void Awake() {
PlayAudioClip(theClip, transform.position, 1);
}
}

sample code:

b33_audio

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon