Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. AudioClip clip = new WWW("File:///" + Application.streamingAssetsPath + "/AudioFile.ogg").GetAudioClipCompressed();
  2.  
  3. //--You can use this audio clip in several ways.
  4.  
  5. //Play it as a background music
  6. JukeboxScript j = FindObjectOfType<JukeboxScript>();
  7. j.Custom.clip = clip;
  8. j.PlayCustom();
  9.  
  10. //Just play it one shot
  11. AudioSource src = FindObjectOfType<AudioListener>().gameObject.AddComponent<AudioSource>();
  12. src.clip = clip;
  13. src.Play();
  14.  
  15. //Play it attached to the game object
  16. GameObject clipOwner = new GameObject();
  17. AudioClipPlayer.PlayAttached(clip, attachedGameObj.transform.position, attachedGameObj.transform, 1f, maxDistance, out clipOwner, Yandere.transform.position.y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement