Exemple #1
0
    void OnMouseDown()
    {
        switch (gameObject.name)
        {
        case "play":
            if (assistantAudioSource.isPlaying)
            {
                rayCastScript.pauseAudio();
//                    assistantAudioSource.Pause();
                GetComponent <Renderer>().material = (Material)Resources.Load("playButton", typeof(Material));
            }
            else
            {
                rayCastScript.unPauseAudio();
//                    assistantAudioSource.UnPause();
                GetComponent <Renderer>().material = (Material)Resources.Load("pauseButton", typeof(Material));
            }
            break;

        case "prev":

            rayCastScript.prevAudio();

//                float currenttimeofaudio = assistantAudioSource.time;
//                int[] rewindarray = timingIntervalForAudio.ToArray(typeof(int)) as int[];
//                var indexofclosesttimeofaudioforrewind = timingIntervalForAudio.IndexOf(rewindarray, rewindarray.OrderBy(a => Math.Abs(currenttimeofaudio - a)).First());
//                assistantAudioSource.Stop();
//                assistantAudioSource.time = rewindarray[indexofclosesttimeofaudioforrewind - 1];
//                assistantAudioSource.Play();
            break;

        case "next":

            rayCastScript.nextAudio();

//                currenttimeofaudio = assistantAudioSource.time;
//                int[] array = timingIntervalForAudio.ToArray(typeof(int)) as int[];
//                var indexofclosesttimeofaudio = timingIntervalForAudio.IndexOf(array, array.OrderBy(a => Math.Abs(currenttimeofaudio - a)).First());
//                assistantAudioSource.Stop();
//                assistantAudioSource.time = array[indexofclosesttimeofaudio + 1];
//                assistantAudioSource.Play();
            break;
        }
    }