ES2.LoadAudio

public static AudioClip LoadAudio(string path)

Parameters

[table th=”0″]path,”The absolute path of the audio file we wish to load.”[/table]

Returns

[table th=”0″]AudioClip,”Our loaded audio as an AudioClip.”[/table]

Description

Loads an Audio file at the given path as an AudioClip.

Ogg files can only be loaded from PC and Mac.
MP3 files can only be loaded from mobile devices.
WAV, XM, IT, MOD and S3M files can be loaded from all supported platforms.

The AudioClip is fully loaded before being returned, rather than being streamed.

C#

// Load a local Ogg file, assign it to our AudioSource and play it
audio.clip = ES2.LoadAudio("C:/Users/User/Documents/MyAudio.ogg");
audio.Play();

JS

// Load a local Ogg file, assign it to our AudioSource and play it
audio.clip = ES2.LoadAudio("C:/Users/User/Documents/MyAudio.ogg");
audio.Play();