private GetChannelCount ( |
||
clip | ||
Résultat | int |
public override string GetInfoString() { AudioClip clip = target as AudioClip; int c = AudioUtil.GetChannelCount(clip); string ch = c == 1 ? "Mono" : c == 2 ? "Stereo" : (c - 1).ToString() + ".1"; AudioCompressionFormat platformFormat = AudioUtil.GetTargetPlatformSoundCompressionFormat(clip); AudioCompressionFormat editorFormat = AudioUtil.GetSoundCompressionFormat(clip); string s = platformFormat.ToString(); if (platformFormat != editorFormat) { s += " (" + editorFormat.ToString() + " in editor" + ")"; } s += ", " + AudioUtil.GetFrequency(clip) + " Hz, " + ch + ", "; System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(clip)); if ((uint)AudioUtil.GetDuration(clip) == 0xffffffff) { s += "Unlimited"; } else { s += string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds); } return(s); }
public override string GetInfoString() { AudioClip clip = this.target as AudioClip; int channelCount = AudioUtil.GetChannelCount(clip); string text = (channelCount != 1) ? ((channelCount != 2) ? ((channelCount - 1).ToString() + ".1") : "Stereo") : "Mono"; string str = string.Concat(new object[] { AudioUtil.GetSoundCompressionFormat(clip).ToString(), ", ", AudioUtil.GetFrequency(clip), " Hz, ", text, ", " }); TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(clip)); if ((uint)AudioUtil.GetDuration(clip) == 4294967295u) { str += "Unlimited"; } else { str += string.Format("{0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds); } str += ", "; return(str + EditorUtility.FormatBytes(AudioUtil.GetSoundSize(clip))); }
public override string GetInfoString() { AudioClip target = this.target as AudioClip; int channelCount = AudioUtil.GetChannelCount(target); string str1; switch (channelCount) { case 1: str1 = "Mono"; break; case 2: str1 = "Stereo"; break; default: str1 = (channelCount - 1).ToString() + ".1"; break; } string str2 = str1; AudioCompressionFormat compressionFormat1 = AudioUtil.GetTargetPlatformSoundCompressionFormat(target); AudioCompressionFormat compressionFormat2 = AudioUtil.GetSoundCompressionFormat(target); string str3 = compressionFormat1.ToString(); if (compressionFormat1 != compressionFormat2) { str3 = str3 + " (" + compressionFormat2.ToString() + " in editor)"; } string str4 = str3 + ", " + (object)AudioUtil.GetFrequency(target) + " Hz, " + str2 + ", "; TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(target)); return((int)(uint)AudioUtil.GetDuration(target) != -1 ? str4 + string.Format("{0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds) : str4 + "Unlimited"); }
public override string GetInfoString() { AudioClip target = this.target as AudioClip; int channelCount = AudioUtil.GetChannelCount(target); string str = (channelCount != 1) ? ((channelCount != 2) ? (((channelCount - 1)).ToString() + ".1") : "Stereo") : "Mono"; AudioCompressionFormat targetPlatformSoundCompressionFormat = AudioUtil.GetTargetPlatformSoundCompressionFormat(target); AudioCompressionFormat soundCompressionFormat = AudioUtil.GetSoundCompressionFormat(target); string str2 = targetPlatformSoundCompressionFormat.ToString(); if (targetPlatformSoundCompressionFormat != soundCompressionFormat) { str2 = str2 + " (" + soundCompressionFormat.ToString() + " in editor)"; } string str3 = str2; object[] objArray1 = new object[] { str3, ", ", AudioUtil.GetFrequency(target), " Hz, ", str, ", " }; str2 = string.Concat(objArray1); TimeSpan span = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(target)); if (((uint)AudioUtil.GetDuration(target)) == uint.MaxValue) { return(str2 + "Unlimited"); } return(str2 + string.Format("{0:00}:{1:00}.{2:000}", span.Minutes, span.Seconds, span.Milliseconds)); }
public override string GetInfoString() { AudioClip clip = base.target as AudioClip; int channelCount = AudioUtil.GetChannelCount(clip); string text = (channelCount != 1) ? ((channelCount != 2) ? ((channelCount - 1).ToString() + ".1") : "Stereo") : "Mono"; AudioCompressionFormat targetPlatformSoundCompressionFormat = AudioUtil.GetTargetPlatformSoundCompressionFormat(clip); AudioCompressionFormat soundCompressionFormat = AudioUtil.GetSoundCompressionFormat(clip); string text2 = targetPlatformSoundCompressionFormat.ToString(); if (targetPlatformSoundCompressionFormat != soundCompressionFormat) { text2 = text2 + " (" + soundCompressionFormat.ToString() + " in editor)"; } string text3 = text2; text2 = string.Concat(new object[] { text3, ", ", AudioUtil.GetFrequency(clip), " Hz, ", text, ", " }); TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(clip)); if ((uint)AudioUtil.GetDuration(clip) == 4294967295u) { text2 += "Unlimited"; } else { text2 += string.Format("{0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds); } return(text2); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (s_DefaultIcon == null) { Init(); } AudioClip clip = target as AudioClip; Event evt = Event.current; if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used) { int px2sample = (AudioUtil.GetSampleCount(clip) / (int)r.width); switch (evt.type) { case EventType.MouseDrag: case EventType.MouseDown: { if (r.Contains(evt.mousePosition) && !AudioUtil.IsMovieAudio(clip)) { if (m_PlayingClip != clip || !AudioUtil.IsClipPlaying(clip)) { AudioUtil.StopAllClips(); AudioUtil.PlayClip(clip, 0, m_bLoop); m_PlayingClip = clip; m_PlayingInspector = this; } AudioUtil.SetClipSamplePosition(clip, px2sample * (int)evt.mousePosition.x); evt.Use(); } } break; } return; } if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } int c = AudioUtil.GetChannelCount(clip); m_wantedRect = new Rect(r.x, r.y, r.width, r.height); float sec2px = ((float)m_wantedRect.width / clip.length); bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip) || AudioUtil.IsMovieAudio(clip)); if (!previewAble) { float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 : r.y + (r.height / 2) - 25; if (r.width > 64) { if (AudioUtil.IsTrackerFile(clip)) { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels.")); } else if (AudioUtil.IsMovieAudio(clip)) { if (r.width > 450) { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie. To audition the sound, play the movie."); } else { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie."); EditorGUI.DropShadowLabel(new Rect(r.x, labelY + 10, r.width, 20), "To audition the sound, play the movie."); } } else { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file"); } } if (m_PlayingInspector == this && m_PlayingClip == clip) { float t = AudioUtil.GetClipPosition(clip); System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f)); EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds)); } } else { PreviewGUI.BeginScrollView(m_wantedRect, m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); if (Event.current.type == EventType.Repaint) { DoRenderPreview(clip, AudioUtil.GetImporterFromClip(clip), m_wantedRect, 1.0f); } for (int i = 0; i < c; ++i) { if (c > 1 && r.width > 64) { var labelRect = new Rect(m_wantedRect.x + 5, m_wantedRect.y + (m_wantedRect.height / c) * i, 30, 20); EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString()); } } if (m_PlayingInspector == this && m_PlayingClip == clip) { float t = AudioUtil.GetClipPosition(clip); System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f)); GUI.DrawTexture(new Rect(m_wantedRect.x + (int)(sec2px * t), m_wantedRect.y, 2, m_wantedRect.height), EditorGUIUtility.whiteTexture); if (r.width > 64) { EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds)); } else { EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds)); } } PreviewGUI.EndScrollView(); } // autoplay start? if (m_bAutoPlay && m_PlayingClip != clip && m_PlayingInspector == this) { AudioUtil.StopAllClips(); AudioUtil.PlayClip(clip, 0, m_bLoop); m_PlayingClip = clip; m_PlayingInspector = this; } // force update GUI if (playing) { GUIView.current.Repaint(); } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (s_DefaultIcon == null) { Init(); } AudioClip clip = target as AudioClip; Event evt = Event.current; if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used) { switch (evt.type) { case EventType.MouseDrag: case EventType.MouseDown: { if (r.Contains(evt.mousePosition)) { var startSample = (int)(evt.mousePosition.x * (AudioUtil.GetSampleCount(clip) / (int)r.width)); if (!AudioUtil.IsClipPlaying(clip) || clip != m_Clip) { PlayClip(clip, startSample, s_Loop); } else { AudioUtil.SetClipSamplePosition(clip, startSample); } evt.Use(); } } break; } return; } if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } int c = AudioUtil.GetChannelCount(clip); s_WantedRect = new Rect(r.x, r.y, r.width, r.height); float sec2px = ((float)s_WantedRect.width / clip.length); bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip)); if (!previewAble) { float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 : r.y + (r.height / 2) - 25; if (r.width > 64) { if (AudioUtil.IsTrackerFile(clip)) { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels.")); } else { EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file"); } } if (m_Clip == clip) { float t = AudioUtil.GetClipPosition(clip); System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f)); EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds)); } } else { PreviewGUI.BeginScrollView(s_WantedRect, m_Position, s_WantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); if (Event.current.type == EventType.Repaint) { DoRenderPreview(true, clip, AudioUtil.GetImporterFromClip(clip), s_WantedRect, 1.0f); } for (int i = 0; i < c; ++i) { if (c > 1 && r.width > 64) { var labelRect = new Rect(s_WantedRect.x + 5, s_WantedRect.y + (s_WantedRect.height / c) * i, 30, 20); EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString()); } } if (m_Clip == clip) { float t = AudioUtil.GetClipPosition(clip); System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f)); GUI.DrawTexture(new Rect(s_WantedRect.x + (int)(sec2px * t), s_WantedRect.y, 2, s_WantedRect.height), EditorGUIUtility.whiteTexture); if (r.width > 64) { EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds)); } else { EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds)); } } PreviewGUI.EndScrollView(); } if (!m_MultiEditing && (s_PlayFirst || (s_AutoPlay && m_Clip != clip))) { // Autoplay preview PlayClip(clip, 0, s_Loop); s_PlayFirst = false; } // force update GUI if (playing) { GUIView.current.Repaint(); } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (AudioClipInspector.s_DefaultIcon == null) { AudioClipInspector.Init(); } AudioClip audioClip = base.target as AudioClip; Event current = Event.current; if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used) { int num = AudioUtil.GetSampleCount(audioClip) / (int)r.width; EventType type = current.type; if (type == EventType.MouseDrag || type == EventType.MouseDown) { if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(audioClip)) { if (this.m_PlayingClip != audioClip) { AudioUtil.StopAllClips(); AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop); this.m_PlayingClip = audioClip; } AudioUtil.SetClipSamplePosition(audioClip, num * (int)current.mousePosition.x); current.Use(); } } } else { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } int channelCount = AudioUtil.GetChannelCount(audioClip); AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height); float num2 = AudioClipInspector.m_wantedRect.width / audioClip.length; if (!AudioUtil.HasPreview(audioClip) && (AudioUtil.IsTrackerFile(audioClip) || AudioUtil.IsMovieAudio(audioClip))) { float num3 = (r.height <= 150f) ? (r.y + r.height / 2f - 25f) : (r.y + r.height / 2f - 10f); if (r.width > 64f) { if (AudioUtil.IsTrackerFile(audioClip)) { EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(audioClip) + " channels.", new object[0])); } else if (AudioUtil.IsMovieAudio(audioClip)) { if (r.width > 450f) { EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie."); } else { EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie."); EditorGUI.DropShadowLabel(new Rect(r.x, num3 + 10f, r.width, 20f), "To audition the sound, play the movie."); } } else { EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Can not show PCM data for this file"); } } if (this.m_PlayingClip == audioClip) { float clipPosition = AudioUtil.GetClipPosition(audioClip); TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f)); EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds)); } } else { PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); if (Event.current.type == EventType.Repaint) { this.DoRenderPreview(audioClip, AudioUtil.GetImporterFromClip(audioClip), AudioClipInspector.m_wantedRect, 1f); } for (int i = 0; i < channelCount; i++) { if (channelCount > 1 && r.width > 64f) { Rect position = new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)i, 30f, 20f); EditorGUI.DropShadowLabel(position, "ch " + (i + 1).ToString()); } } if (this.m_PlayingClip == audioClip) { float clipPosition2 = AudioUtil.GetClipPosition(audioClip); TimeSpan timeSpan2 = new TimeSpan(0, 0, 0, 0, (int)(clipPosition2 * 1000f)); GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)((int)(num2 * clipPosition2)), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), EditorGUIUtility.whiteTexture); if (r.width > 64f) { EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", timeSpan2.Minutes, timeSpan2.Seconds, timeSpan2.Milliseconds)); } else { EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", timeSpan2.Minutes, timeSpan2.Seconds)); } if (!AudioUtil.IsClipPlaying(audioClip)) { this.m_PlayingClip = null; } } PreviewGUI.EndScrollView(); } if (AudioClipInspector.m_bPlayFirst) { AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop); this.m_PlayingClip = audioClip; AudioClipInspector.m_bPlayFirst = false; } if (this.playing) { GUIView.current.Repaint(); } } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if ((UnityEngine.Object)AudioClipInspector.s_DefaultIcon == (UnityEngine.Object)null) { AudioClipInspector.Init(); } AudioClip target = this.target as AudioClip; Event current = Event.current; if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used) { int num = AudioUtil.GetSampleCount(target) / (int)r.width; switch (current.type) { case EventType.MouseDown: case EventType.MouseDrag: if (!r.Contains(current.mousePosition) || AudioUtil.IsMovieAudio(target)) { break; } if ((UnityEngine.Object) this.m_PlayingClip != (UnityEngine.Object)target) { AudioUtil.StopAllClips(); AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop); this.m_PlayingClip = target; } AudioUtil.SetClipSamplePosition(target, num * (int)current.mousePosition.x); current.Use(); break; } } else { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } int channelCount = AudioUtil.GetChannelCount(target); AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height); float num = AudioClipInspector.m_wantedRect.width / target.length; if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) ? 1 : (AudioUtil.IsMovieAudio(target) ? 1 : 0)) != 0) { float y = (double)r.height <= 150.0 ? (float)((double)r.y + (double)r.height / 2.0 - 25.0) : (float)((double)r.y + (double)r.height / 2.0 - 10.0); if ((double)r.width > 64.0) { if (AudioUtil.IsTrackerFile(target)) { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + (object)AudioUtil.GetMusicChannelCount(target) + " channels.")); } else if (AudioUtil.IsMovieAudio(target)) { if ((double)r.width > 450.0) { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie."); } else { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie."); EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie."); } } else { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file"); } } if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target) { TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)((double)AudioUtil.GetClipPosition(target) * 1000.0)); EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds)); } } else { PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, (GUIStyle)"PreHorizontalScrollbar", (GUIStyle)"PreHorizontalScrollbarThumb"); if (Event.current.type == EventType.Repaint) { this.DoRenderPreview(target, AudioUtil.GetImporterFromClip(target), AudioClipInspector.m_wantedRect, 1f); } for (int index = 0; index < channelCount; ++index) { if (channelCount > 1 && (double)r.width > 64.0) { EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)index, 30f, 20f), "ch " + (index + 1).ToString()); } } if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target) { float clipPosition = AudioUtil.GetClipPosition(target); TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)((double)clipPosition * 1000.0)); GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)(int)((double)num * (double)clipPosition), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), (Texture)EditorGUIUtility.whiteTexture); if ((double)r.width > 64.0) { EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds)); } else { EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", (object)timeSpan.Minutes, (object)timeSpan.Seconds)); } if (!AudioUtil.IsClipPlaying(target)) { this.m_PlayingClip = (AudioClip)null; } } PreviewGUI.EndScrollView(); } if (AudioClipInspector.m_bPlayFirst) { AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop); this.m_PlayingClip = target; AudioClipInspector.m_bPlayFirst = false; } if (!this.playing) { return; } GUIView.current.Repaint(); } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (s_DefaultIcon == null) { Init(); } AudioClip target = this.target as AudioClip; Event current = Event.current; if (((current.type == EventType.Repaint) || (current.type == EventType.Layout)) || (current.type == EventType.Used)) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } int channelCount = AudioUtil.GetChannelCount(target); m_wantedRect = new Rect(r.x, r.y, r.width, r.height); float num3 = m_wantedRect.width / target.length; if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) || AudioUtil.IsMovieAudio(target))) { float y = (r.height <= 150f) ? ((r.y + (r.height / 2f)) - 25f) : ((r.y + (r.height / 2f)) - 10f); if (r.width > 64f) { if (AudioUtil.IsTrackerFile(target)) { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(target) + " channels.", new object[0])); } else if (AudioUtil.IsMovieAudio(target)) { if (r.width > 450f) { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie."); } else { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie."); EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie."); } } else { EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file"); } } if (this.m_PlayingClip == target) { float clipPosition = AudioUtil.GetClipPosition(target); TimeSpan span = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f)); EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", span.Minutes, span.Seconds, span.Milliseconds)); } } else { PreviewGUI.BeginScrollView(m_wantedRect, this.m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); Texture2D image = null; if (r.width < 100f) { image = AssetPreview.GetAssetPreview(target); } else { image = AudioUtil.GetWaveFormFast(target, 1, 0, target.samples, r.width, r.height); } if (image == null) { Rect position = new Rect { x = ((m_wantedRect.width - s_DefaultIcon.width) / 2f) + m_wantedRect.x, y = ((m_wantedRect.height - s_DefaultIcon.height) / 2f) + m_wantedRect.y, width = s_DefaultIcon.width, height = s_DefaultIcon.height }; GUI.DrawTexture(position, s_DefaultIcon); base.Repaint(); } else { GUI.DrawTexture(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, m_wantedRect.height), image); } for (int i = 0; i < channelCount; i++) { if ((channelCount > 1) && (r.width > 64f)) { Rect rect2 = new Rect(m_wantedRect.x + 5f, m_wantedRect.y + ((m_wantedRect.height / ((float)channelCount)) * i), 30f, 20f); EditorGUI.DropShadowLabel(rect2, "ch " + ((i + 1)).ToString()); } } if (this.m_PlayingClip == target) { float num7 = AudioUtil.GetClipPosition(target); TimeSpan span2 = new TimeSpan(0, 0, 0, 0, (int)(num7 * 1000f)); GUI.DrawTexture(new Rect(m_wantedRect.x + ((int)(num3 * num7)), m_wantedRect.y, 2f, m_wantedRect.height), EditorGUIUtility.whiteTexture); if (r.width > 64f) { EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", span2.Minutes, span2.Seconds, span2.Milliseconds)); } else { EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", span2.Minutes, span2.Seconds)); } if (!AudioUtil.IsClipPlaying(target)) { this.m_PlayingClip = null; } } PreviewGUI.EndScrollView(); } if (m_bPlayFirst) { AudioUtil.PlayClip(target, 0, m_bLoop); this.m_PlayingClip = target; m_bPlayFirst = false; } if (this.playing) { GUIView.current.Repaint(); } } else { int num = AudioUtil.GetSampleCount(target) / ((int)r.width); switch (current.type) { case EventType.MouseDown: case EventType.MouseDrag: if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(target)) { if (this.m_PlayingClip != target) { AudioUtil.StopAllClips(); AudioUtil.PlayClip(target, 0, m_bLoop); this.m_PlayingClip = target; } AudioUtil.SetClipSamplePosition(target, num * ((int)current.mousePosition.x)); current.Use(); } break; } } }