J’aimerai savoir comment charger des sons dans un tableau audioclip en utilisant Resources.Load.
Quant je dépose mes son par glisser déposer sa marche mais j'ai besoin de renseigner les path avec Resources.Load.
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
[ RequireComponent (typeof ( AudioSource ))]
public class son : MonoBehaviour {
AudioSource audio;
private AudioClip[] sons;
void Start (){
sons = new AudioClip[]{(AudioClip)Resources.Load(Application.dataPath +"/Resources/mots/ancre/ancre.ogg"),
(AudioClip)Resources.Load(Application.dataPath +"/Resources/mots/ange/ange.ogg"),
(AudioClip)Resources.Load(Application.dataPath +"Resources/mots/anglais/anglais.ogg"),
(AudioClip)Resources.Load(Application.dataPath +"Resources/mots/antenne/antenne.ogg")};
audio = GetComponent<AudioSource>();
}
IEnumerator OnTriggerEnter(Collider other) {
modifier_text.les_mots.text=PlayerPrefs.GetString("mot"+modifier_text.incremente);
audio.clip = sons[modifier_text.numeroMot+1];
audio.Play();
yield return new WaitForSeconds (audio.clip.length);
modifier_text.numeroMot++;
modifier_text.incremente++;
Destroy(gameObject);
}
void Update () {
}
}