private void OnDisable() { EditorApplication.update -= Update; i_pauseSample = 0; EAudio.StopClip(); EditorUtility.SetDirty(target); beats.ForceSort(); }
void Stop() { i_curSelectPos = -1; b_pause = false; i_pauseSample = 0; EAudio.StopClip(); f_beatCheck = 0f; }
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; }
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; }
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)); }
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(); }
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); }
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(); }
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; } } }
void Resume() { EAudio.ResumeClip(); EAudio.SetSamplePosition(i_pauseSample); b_pause = false; }
void Play() { b_pause = false; i_pauseSample = 0; EAudio.PlayClip(); }
void Pause() { i_pauseSample = EAudio.GetCurSample(); EAudio.PauseClip(); b_pause = true; }
private IEnumerator BackgroundSoundsCoroutine(float previousSoundDuration, EAudio audioType) { yield return(new WaitForSeconds(previousSoundDuration)); PlayBackgroundSounds(audioType); }