Exemplo n.º 1
0
    public void LoadAudioClip()
    {
        AudioClip clip = (AudioClip)AssetDatabase.LoadAssetAtPath(PATH_TO_WAV + soundKey.ToString() + pitchOffset + ".wav", typeof(AudioClip));

        audioSource.clip = clip;
        text.text        = soundKey.ToString() + pitchOffset;
    }
Exemplo n.º 2
0
        public void PlaySound(SoundKey key)
        {
            CheckDisposed();

            Cue sound = m_soundBank.GetCue(key.ToString());

            sound.Play();
        }
Exemplo n.º 3
0
    IEnumerator GetAudioClip()
    {
        using (UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(PATH_TO_WAV + soundKey.ToString() + pitchOffset + ".wav", AudioType.WAV))
        {
            request.uri = new Uri(request.uri.AbsoluteUri.Replace("http://localhost", "file:/"));
            request.url = request.url.Replace("http://localhost", "file:/");

            yield return(request.SendWebRequest());

            if (request.result == UnityWebRequest.Result.Success)
            {
                AudioClip clip = DownloadHandlerAudioClip.GetContent(request);
                audioSource.clip = clip;
            }
            else
            {
                Debug.Log(PATH_TO_WAV + soundKey.ToString() + pitchOffset + ".wav not found.");
            }
        }
    }