private void DrawTimeline() { GUILayout.BeginVertical(); var soundTime = this.m_SoundAudio == null ? 1 : this.m_SoundAudio.length; GUILayout.Label("File length: " + (this.m_SoundAudio == null ? "0s" : (int)this.m_SoundAudio.length + "s") + "\n" + "Position: " + (int)this.m_SoundTimeLine + "s"); GUILayout.BeginHorizontal(); if (GUILayout.Button("<<", GUILayout.Width(30f))) { if (this.m_SoundAudio == null) { return; } this.m_SoundTimeLine = this.m_SoundTimeLine <= 1 ? 0 : this.m_SoundTimeLine - 1; // Set sound line var clipPosition = this.m_SoundTimeLine * AudioUtility.GetFrequency(this.m_SoundAudio); AudioUtility.SetClipSamplePosition(this.m_SoundAudio, (int)clipPosition); } // Sound play line this.m_SoundTimeLine = GUILayout.HorizontalSlider(this.m_SoundTimeLine, 0, soundTime); this.m_SoundLineRect = GUILayoutUtility.GetLastRect(); if (this.m_SoundAudio != null) { if (this.m_IsPause == false) { // Update sound line this.m_SoundTimeLine = AudioUtility.GetClipPosition(this.m_SoundAudio); if (this.m_PreviousSoundTimeLine != (int)this.m_SoundTimeLine) { this.m_PreviousSoundTimeLine = (int)this.m_SoundTimeLine; } } else { // Set sound line var clipPosition = this.m_SoundTimeLine * AudioUtility.GetFrequency(this.m_SoundAudio); AudioUtility.SetClipSamplePosition(this.m_SoundAudio, (int)clipPosition); } } if (GUILayout.Button(">>", GUILayout.Width(30f))) { if (this.m_SoundAudio == null) { return; } this.m_SoundTimeLine = this.m_SoundTimeLine >= this.m_SoundAudio.length - 1 ? this.m_SoundAudio.length : this.m_SoundTimeLine + 1; // Set sound line var clipPosition = this.m_SoundTimeLine * AudioUtility.GetFrequency(this.m_SoundAudio); AudioUtility.SetClipSamplePosition(this.m_SoundAudio, (int)clipPosition); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }