private void OnGUI() { if (m_Info != null && m_DebugGui) { GUI.depth = -1000; GUI.matrix = Matrix4x4.TRS(new Vector3((float)m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(1.5f, 1.5f, 1f)); GUILayout.BeginVertical("box", GUILayout.MaxWidth(180f)); GUILayout.Label(Path.GetFileName(m_VideoPath)); GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2")); GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s"); GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz"); if (TextureProducer != null && TextureProducer.GetTexture() != null) { GUILayout.BeginHorizontal(); Rect rect = GUILayoutUtility.GetRect(32f, 32f); GUILayout.Space(8f); Rect rect2 = GUILayoutUtility.GetRect(32f, 32f); Matrix4x4 matrix = GUI.matrix; if (TextureProducer.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0f, rect.y + rect.height / 2f)); } GUI.DrawTexture(rect, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, alphaBlend: false); GUI.DrawTexture(rect2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, alphaBlend: true); GUI.matrix = matrix; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } }
void OnGUI() { if (Event.current.type == EventType.Layout) { SetGuiPositionFromVideoIndex(_debugOverlayCount++); } if (_mediaPlayer != null && _mediaPlayer.Info != null) { IMediaInfo info = _mediaPlayer.Info; IMediaControl control = _mediaPlayer.Control; IMediaProducer textureProducer = _mediaPlayer.TextureProducer; GUI.depth = _guiDepth; GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(_displaySize, _displaySize, 1.0f)); GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth)); GUILayout.Label(System.IO.Path.GetFileName(_mediaPlayer.m_VideoPath)); GUILayout.Label("Dimensions: " + info.GetVideoWidth() + "x" + info.GetVideoHeight() + "@" + info.GetVideoFrameRate().ToString("F2")); GUILayout.Label("Time: " + (control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (info.GetDurationMs() * 0.001f).ToString("F1") + "s"); GUILayout.Label("Rate: " + info.GetVideoDisplayRate().ToString("F2") + "Hz"); if (_mediaPlayer.m_Resample && _mediaPlayer.FrameResampler != null) { Resampler resampler = _mediaPlayer.FrameResampler; GUILayout.BeginVertical(); GUILayout.Label("Resampler Info:"); GUILayout.Label("Resampler timestamp: " + resampler.TextureTimeStamp); GUILayout.Label("Resampler frames dropped: " + resampler.DroppedFrames); GUILayout.Label("Resampler frame displayed timer: " + resampler.FrameDisplayedTimer); GUILayout.EndVertical(); } if (textureProducer != null && textureProducer.GetTexture() != null) { #if REAL_ANDROID // In OES mode we can't display the texture without using a special shader, so just don't display it if (!_optionsAndroid.useFastOesPath) #endif { // Show texture without and with alpha blending GUILayout.BeginHorizontal(); Rect r1 = GUILayoutUtility.GetRect(32f, 32f); GUILayout.Space(8f); Rect r2 = GUILayoutUtility.GetRect(32f, 32f); Matrix4x4 prevMatrix = GUI.matrix; if (textureProducer.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2f))); } GUI.DrawTexture(r1, textureProducer.GetTexture(), ScaleMode.ScaleToFit, false); GUI.DrawTexture(r2, textureProducer.GetTexture(), ScaleMode.ScaleToFit, true); GUI.matrix = prevMatrix; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } if (_displayControls) { GUILayout.BeginHorizontal(); if (control.IsPaused()) { if (GUILayout.Button("Play", GUILayout.Width(50))) { control.Play(); } } else { if (GUILayout.Button("Pause", GUILayout.Width(50))) { control.Pause(); } } float duration = info.GetDurationMs(); float time = control.GetCurrentTimeMs(); float newTime = GUILayout.HorizontalSlider(time, 0f, duration); if (newTime != time) { control.Seek(newTime); } GUILayout.EndHorizontal(); } #if AVPROVIDEO_DEBUG_DISPLAY_EVENTS // Dirty code to hack in an event monitor if (Event.current.type == EventType.Repaint) { _mediaPlayer.Events.RemoveListener(OnMediaPlayerEvent); _mediaPlayer.Events.AddListener(OnMediaPlayerEvent); UpdateEventLogs(); } if (_eventLog != null && _eventLog.Count > 0) { GUILayout.Label("Recent Events: "); GUILayout.BeginVertical("box"); int eventIndex = 0; foreach (string eventString in _eventLog) { GUI.color = Color.white; if (eventIndex == 0) { GUI.color = new Color(1f, 1f, 1f, _eventTimer); } GUILayout.Label(eventString); eventIndex++; } GUILayout.EndVertical(); GUI.color = Color.white; } #endif GUILayout.EndVertical(); } }
public void OnGUI() { if (m_Info != null && m_DebugGui) { GUI.depth = s_GuiDepth; GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(s_GuiScale, s_GuiScale, 1.0f)); GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth)); GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath)); GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2")); GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s"); GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz"); if (TextureProducer != null && TextureProducer.GetTexture() != null) { // Show texture without and with alpha blending GUILayout.BeginHorizontal(); Rect r1 = GUILayoutUtility.GetRect(32f, 32f); GUILayout.Space(8f); Rect r2 = GUILayoutUtility.GetRect(32f, 32f); Matrix4x4 prevMatrix = GUI.matrix; if (TextureProducer.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2))); } GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false); GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true); GUI.matrix = prevMatrix; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } #if AVPROVIDEO_DEBUG_DISPLAY_EVENTS // Dirty code to hack in an event monitor if (Event.current.type == EventType.Repaint) { this.Events.RemoveListener(OnMediaPlayerEvent); this.Events.AddListener(OnMediaPlayerEvent); UpdateEventLogs(); } if (_eventLog != null && _eventLog.Count > 0) { GUILayout.Label("Recent Events: "); GUILayout.BeginVertical("box"); int eventIndex = 0; foreach (string eventString in _eventLog) { GUI.color = Color.white; if (eventIndex == 0) { GUI.color = new Color(1f, 1f, 1f, _eventTimer); } GUILayout.Label(eventString); eventIndex++; } GUILayout.EndVertical(); GUI.color = Color.white; } #endif GUILayout.EndVertical(); } }