Copie depuis Unity VCS vers GitHub
This commit is contained in:
32
Assets/Scripts/PNJInteraction.cs
Normal file
32
Assets/Scripts/PNJInteraction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
|
||||
public class PNJInteraction : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private AudioSource audio;
|
||||
public void Interaction()
|
||||
{
|
||||
Debug.Log("Bonjour, je suis un \"Nolant Peasant Blue\".");
|
||||
audio.Play();
|
||||
StartCoroutine(MajSource());
|
||||
}
|
||||
|
||||
IEnumerator MajSource()
|
||||
{
|
||||
string url = "/audio/2160";
|
||||
using (UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(BuildConstants.LocalIP + ":8000" + url, AudioType.WAV))
|
||||
{
|
||||
yield return req.SendWebRequest();
|
||||
|
||||
if (req.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
audio.clip = DownloadHandlerAudioClip.GetContent(req);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(req.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user