public void PrevBanner() { if (!isBannerReady) { return; } bannerMediaPlaylist.PrevItem(); }
public override void OnInspectorGUI() { PlaylistMediaPlayer media = (this.target) as PlaylistMediaPlayer; serializedObject.Update(); if (media == null || _propPlayerA == null) { return; } if (_sectionBoxStyle == null) { _sectionBoxStyle = new GUIStyle(GUI.skin.box); _sectionBoxStyle.padding.top = 0; _sectionBoxStyle.padding.bottom = 0; } EditorGUILayout.PropertyField(_propPlayerA); EditorGUILayout.PropertyField(_propPlayerB); EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Audio", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_propAudioVolume, new GUIContent("Volume")); if (EditorGUI.EndChangeCheck()) { foreach (PlaylistMediaPlayer player in this.targets) { player.AudioVolume = _propAudioVolume.floatValue; } } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_propAudioMuted, new GUIContent("Muted")); if (EditorGUI.EndChangeCheck()) { foreach (PlaylistMediaPlayer player in this.targets) { player.AudioMuted = _propAudioMuted.boolValue; } } EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Playlist", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propPlaylistAutoProgress, new GUIContent("Auto Progress")); EditorGUILayout.PropertyField(_propPlaylistLoopMode, new GUIContent("Loop Mode")); EditorGUILayout.PropertyField(_propAutoCloseVideo); { EditorGUILayout.Space(); EditorGUILayout.Space(); GUI.color = Color.white; GUI.backgroundColor = Color.clear; if (_expandPlaylistItems) { GUI.color = Color.white; GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.1f); if (EditorGUIUtility.isProSkin) { GUI.backgroundColor = Color.black; } } GUILayout.BeginVertical(_sectionBoxStyle); GUI.backgroundColor = Color.white; if (GUILayout.Button("Playlist Items", EditorStyles.toolbarButton)) { _expandPlaylistItems = !_expandPlaylistItems; } GUI.color = Color.white; if (_expandPlaylistItems) { EditorGUILayout.PropertyField(_propPlaylist); } GUILayout.EndVertical(); } EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Default Transition", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propDefaultTransition, new GUIContent("Transition")); EditorGUILayout.PropertyField(_propDefaultTransitionEasing, new GUIContent("Easing")); EditorGUILayout.PropertyField(_propDefaultTransitionDuration, new GUIContent("Duration")); EditorGUILayout.PropertyField(_propPausePreviousOnTransition, new GUIContent("Pause Previous")); EditorGUILayout.Space(); EditorGUILayout.Space(); if (Application.isPlaying) { ITextureProducer textureSource = media.TextureProducer; Texture texture = null; if (textureSource != null) { texture = textureSource.GetTexture(); } if (texture == null) { texture = EditorGUIUtility.whiteTexture; } float ratio = 1f; // (float)texture.width / (float)texture.height; // Reserve rectangle for texture GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Rect textureRect; Rect alphaRect = new Rect(0f, 0f, 1f, 1f); if (texture != EditorGUIUtility.whiteTexture) { textureRect = GUILayoutUtility.GetRect(Screen.width / 2, Screen.width / 2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio); } else { textureRect = GUILayoutUtility.GetRect(1920f / 40f, 1080f / 40f); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); string rateText = "0"; string playerText = string.Empty; if (media.Info != null) { rateText = media.Info.GetVideoDisplayRate().ToString("F2"); playerText = media.Info.GetPlayerDescription(); } EditorGUILayout.LabelField("Display Rate", rateText); EditorGUILayout.LabelField("Using", playerText); // Draw the texture Matrix4x4 prevMatrix = GUI.matrix; if (textureSource != null && textureSource.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2))); } if (!GUI.enabled) { GUI.color = Color.grey; GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false); GUI.color = Color.white; } else { { GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false); EditorGUI.DrawTextureAlpha(alphaRect, texture, ScaleMode.ScaleToFit); } } GUI.matrix = prevMatrix; } EditorGUI.BeginDisabledGroup(!(media.Control != null && media.Control.CanPlay() && media.isActiveAndEnabled && !EditorApplication.isPaused)); OnInspectorGUI_PlayControls(media.Control, media.Info); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(!Application.isPlaying); GUILayout.Label("Current Item: " + media.PlaylistIndex + " / " + Mathf.Max(0, media.Playlist.Items.Count - 1)); GUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex - 1)); if (GUILayout.Button("Prev")) { media.PrevItem(); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex + 1)); if (GUILayout.Button("Next")) { media.NextItem(); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { PlaylistMediaPlayer media = (this.target) as PlaylistMediaPlayer; serializedObject.Update(); if (media == null || _propPlayerA == null) { return; } EditorGUILayout.PropertyField(_propPlayerA); EditorGUILayout.PropertyField(_propPlayerB); EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Playlist", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propPlaylistLoopMode, new GUIContent("Loop Mode")); EditorGUILayout.PropertyField(_propPlaylist, new GUIContent("Items"), true); EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Transition", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propNextTransition, new GUIContent("Next")); EditorGUILayout.PropertyField(_propTransitionEasing, new GUIContent("Easing")); EditorGUILayout.PropertyField(_propTransitionDuration, new GUIContent("Duration")); EditorGUILayout.PropertyField(_propPausePreviousOnTransition, new GUIContent("Pause Previous")); EditorGUILayout.Space(); EditorGUILayout.Space(); if (Application.isPlaying) { IMediaProducer textureSource = media.TextureProducer; Texture texture = null; if (textureSource != null) { texture = textureSource.GetTexture(); } if (texture == null) { texture = EditorGUIUtility.whiteTexture; } float ratio = (float)texture.width / (float)texture.height; // Reserve rectangle for texture GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Rect textureRect; Rect alphaRect = new Rect(0f, 0f, 1f, 1f); if (texture != EditorGUIUtility.whiteTexture) { textureRect = GUILayoutUtility.GetRect(Screen.width / 2, Screen.width / 2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio); } else { textureRect = GUILayoutUtility.GetRect(1920f / 40f, 1080f / 40f); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); string rateText = "0"; string playerText = string.Empty; if (media.Info != null) { rateText = media.Info.GetVideoDisplayRate().ToString("F2"); playerText = media.Info.GetPlayerDescription(); } EditorGUILayout.LabelField("Display Rate", rateText); EditorGUILayout.LabelField("Using", playerText); // Draw the texture Matrix4x4 prevMatrix = GUI.matrix; if (textureSource != null && textureSource.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2))); } if (!GUI.enabled) { GUI.color = Color.grey; GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false); GUI.color = Color.white; } else { { GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit, false); EditorGUI.DrawTextureAlpha(alphaRect, texture, ScaleMode.ScaleToFit); } } GUI.matrix = prevMatrix; } EditorGUI.BeginDisabledGroup(!(media.Control != null && media.Control.CanPlay() && media.isActiveAndEnabled && !EditorApplication.isPaused)); OnInspectorGUI_PlayControls(media.Control, media.Info); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(!Application.isPlaying); GUILayout.Label("Current Item: " + media.PlaylistIndex + " / " + Mathf.Max(0, media.Playlist.Items.Count - 1)); GUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex - 1)); if (GUILayout.Button("Prev")) { media.PrevItem(); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!media.CanJumpToItem(media.PlaylistIndex + 1)); if (GUILayout.Button("Next")) { media.NextItem(); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }