示例#1
0
 private void OnDisable()
 {
     EditorApplication.update -= Update;
     i_pauseSample             = 0;
     EAudio.StopClip();
     EditorUtility.SetDirty(target);
     beats.ForceSort();
 }
示例#2
0
 void Stop()
 {
     i_curSelectPos = -1;
     b_pause        = false;
     i_pauseSample  = 0;
     EAudio.StopClip();
     f_beatCheck = 0f;
 }
示例#3
0
    void Init()
    {
        EAudio.AttachClipTo(beats.AC_ClipToPlay);
        f_totalTime = beats.AC_ClipToPlay.length;

        f_beatEach    = 60f / beats.I_BeatPerMinute;
        f_beatCheck   = 0f;
        f_beatToScale = 0f;

        i_totalBeats = (int)(f_totalTime / f_beatEach);

        f_sliderStartOffset = beats.F_BeatStartOffset > 0?I_RectHeight * (beats.F_BeatStartOffset / f_totalTime):0;
        f_sliderBeatHeight  = (I_RectHeight - f_sliderStartOffset) / i_totalBeats;
        f_viewBeatHeight    = ((float)I_RectHeight - I_BeatCheckLine) / I_BeatsInView;
    }
示例#4
0
 void SetSongPos(float posTime)
 {
     if (EAudio.IsAudioPlaying())
     {
         EAudio.SetSamplePosition((int)(EAudio.GetSampleDuration() * (posTime / f_totalTime)));
         i_pauseSample = EAudio.GetCurSample();
     }
     else
     {
         Play();
         EAudio.SetSamplePosition((int)(EAudio.GetSampleDuration() * (posTime / f_totalTime)));
         Pause();
     }
     f_beatCheck = 0;
 }
示例#5
0
        public void PlayBackgroundSounds(EAudio audioType)
        {
            AudioStaticData audioData =
                audioClips.TryGetValue(audioType, out AudioStaticData audioStaticData) ? audioStaticData : null;

            if (audioData == null)
            {
                return;
            }

            AudioClip clip = audioData.Clips.GetRandom();

            BackgroundSoundsAudioSource.clip = clip;
            BackgroundSoundsAudioSource.Play();
            StartCoroutine(BackgroundSoundsCoroutine(clip.length, audioType));
        }
示例#6
0
        public void PlayMusic(EAudio audio)
        {
            AudioStaticData audioData =
                audioClips.TryGetValue(audio, out AudioStaticData audioStaticData) ? audioStaticData : null;

            if (audioData == null)
            {
                return;
            }

            AudioClip clip = audioData.Clips.GetRandom();

            MusicAudioSource.clip = clip;
            MusicAudioSource.loop = true;
            MusicAudioSource.Play();
        }
示例#7
0
        public void PlaySound(EAudio audioType)
        {
            AudioStaticData audioData =
                audioClips.TryGetValue(audioType, out AudioStaticData audioStaticData) ? audioStaticData : null;

            if (audioData == null)
            {
                return;
            }

            if (SoundsAudioSource.isPlaying && previousSoundType == audioType)
            {
                return;
            }

            AudioClip clip = audioData.Clips.GetRandom();

            previousSoundType = audioType;
            SoundsAudioSource.PlayOneShot(clip, SoundsAudioSource.volume);
        }
示例#8
0
 void DrawSongConroll()
 {
     f_curTime = EAudio.GetCurTime();
     GUILayout.BeginHorizontal();
     GUILayout.Space(15);
     if (EAudio.IsAudioPlaying())
     {
         if (!b_pause)
         {
             if (GUILayout.Button("Pause(~)"))
             {
                 Pause();
             }
         }
         else
         {
             if (GUILayout.Button("Resume(~)"))
             {
                 Resume();
             }
         }
     }
     else
     {
         if (GUILayout.Button("Play(~)"))
         {
             Play();
         }
     }
     GUILayout.Space(15);
     if (GUILayout.Button("Stop(Esc)"))
     {
         Stop();
     }
     GUILayout.Space(15);
     GUILayout.EndHorizontal();
 }
示例#9
0
    void EventManage()
    {
        if (Event.current.isMouse)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                v2_mousePos = Event.current.mousePosition;
            }
            b_isLeftClick = Event.current.button == 0;
        }
        else if (Event.current.isScrollWheel)
        {
            if (Event.current.delta.y > 0)
            {
                SetSongPos(f_curTime - .5f);
            }
            else if (Event.current.delta.y < 0)
            {
                SetSongPos(f_curTime + .5f);
            }
        }
        else if (Event.current.isKey && Event.current.type == EventType.KeyUp)
        {
            switch (Event.current.keyCode)
            {
            case KeyCode.F12:
            {
                beats.Clear();
            }
            break;

            case KeyCode.BackQuote:
            {
                if (!EAudio.IsAudioPlaying())
                {
                    Play();
                }
                else if (b_pause)
                {
                    Resume();
                }
                else
                {
                    Pause();
                }
            }
            break;

            case KeyCode.Escape:
            {
                if (EAudio.IsAudioPlaying())
                {
                    Stop();
                }
            }
            break;

            case KeyCode.W:
            {
                SetSongPos(f_curTime + 1f);
            }
            break;

            case KeyCode.S:
            {
                SetSongPos(f_curTime - 1f);
            }
            break;
            }
        }
    }
示例#10
0
 void Resume()
 {
     EAudio.ResumeClip();
     EAudio.SetSamplePosition(i_pauseSample);
     b_pause = false;
 }
示例#11
0
 void Play()
 {
     b_pause       = false;
     i_pauseSample = 0;
     EAudio.PlayClip();
 }
示例#12
0
 void Pause()
 {
     i_pauseSample = EAudio.GetCurSample();
     EAudio.PauseClip();
     b_pause = true;
 }
示例#13
0
        private IEnumerator BackgroundSoundsCoroutine(float previousSoundDuration, EAudio audioType)
        {
            yield return(new WaitForSeconds(previousSoundDuration));

            PlayBackgroundSounds(audioType);
        }