private void OnInspectorGUI_Settings() { foreach (AnimCollapseSection section in _settingSections) { AnimCollapseSection.Show(section, indentLevel: 1); } }
private void OnInspectorGUI_Debug() { MediaPlayer mediaPlayer = (this.target) as MediaPlayer; IMediaInfo info = mediaPlayer.Info; if (info != null) { AnimCollapseSection.Show(_sectionDevModeState); AnimCollapseSection.Show(_sectionDevModeTexture); AnimCollapseSection.Show(_sectionDevModePlaybackQuality); } if (info != null) { #if UNITY_EDITOR_WIN if (mediaPlayer.PlatformOptionsWindows.useHapNotchLC) { AnimCollapseSection.Show(_sectionDevModeHapNotchLCDecoder); } if (mediaPlayer.PlatformOptionsWindows.bufferedFrameSelection != BufferedFrameSelectionMode.None) { AnimCollapseSection.Show(_sectionDevModeBufferedFrames); } #endif } else { GUILayout.Label("No media loaded"); } }
//[MenuItem("RenderHeads/AVPro Video/Reset Settings", false, 101)] internal static void DeleteSettings() { EditorPrefs.DeleteKey(SettingsPrefix + "PlatformIndex"); EditorPrefs.DeleteKey(SettingsPrefix + "ShowAlphaChannel"); EditorPrefs.DeleteKey(SettingsPrefix + "AllowDeveloperMode"); EditorPrefs.DeleteKey(SettingsPrefix + "HTTPHeadersToggle"); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Media")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Debug")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Settings")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("About / Help")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Source")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Main")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Audio")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Visual")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Network")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Media")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Subtitles")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Events")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Platform Specific")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName("Global")); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.Windows).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.MacOSX).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.Android).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.iOS).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.tvOS).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.WindowsUWP).text)); EditorPrefs.DeleteKey(AnimCollapseSection.GetPrefName(GetPlatformButtonContent(Platform.WebGL).text)); }
private void OnInspectorGUI_PlatformOverrides() { foreach (AnimCollapseSection section in _platformSections) { AnimCollapseSection.Show(section, indentLevel: 2); } }
private void CreateSections() { const float colorSaturation = 0.66f; Color mediaInfoColor = Color.HSVToRGB(0.55f, colorSaturation, 1f); Color sourceColor = Color.HSVToRGB(0.4f, colorSaturation, 1f); Color platformSpecificColor = Color.HSVToRGB(0.85f, colorSaturation, 1f); Color platformColor = platformSpecificColor; if (EditorGUIUtility.isProSkin) { platformColor *= 0.66f; } _sectionMediaInfo = new AnimCollapseSection("Media Info", false, false, OnInspectorGUI_MediaInfo, this, mediaInfoColor); _sectionDebug = new AnimCollapseSection("Debug", false, true, OnInspectorGUI_Debug, this, Color.white); _sectionSettings = new AnimCollapseSection("Settings", false, true, OnInspectorGUI_Settings, this, Color.white); _sectionAboutHelp = new AnimCollapseSection("About / Help", false, false, OnInspectorGUI_About, this, Color.white); _settingSections.Clear(); _settingSections.Add(new AnimCollapseSection("Source", false, true, OnInspectorGUI_Source, this, sourceColor)); _settingSections.Add(new AnimCollapseSection("Main", false, false, OnInspectorGUI_Main, this, Color.white)); _settingSections.Add(new AnimCollapseSection("Audio", false, false, OnInspectorGUI_Audio, this, Color.white)); _settingSections.Add(new AnimCollapseSection("Visual", true, false, OnInspectorGUI_Visual, this, Color.white)); //_settingSections.Add(new AnimCollapseSection("Network", true, false, OnInspectorGUI_Network, this, Color.white)); _settingSections.Add(new AnimCollapseSection("Subtitles", true, false, OnInspectorGUI_Subtitles, this, Color.white)); _settingSections.Add(new AnimCollapseSection("Events", true, false, OnInspectorGUI_Events, this, Color.white)); _settingSections.Add(new AnimCollapseSection("Platform Specific", true, false, OnInspectorGUI_PlatformOverrides, this, platformSpecificColor)); _settingSections.Add(new AnimCollapseSection("Global", true, false, OnInspectorGUI_GlobalSettings, this, Color.white)); _platformSections.Clear(); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.Windows), true, false, OnInspectorGUI_Override_Windows, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.MacOSX), true, false, OnInspectorGUI_Override_MacOSX, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.Android), true, false, OnInspectorGUI_Override_Android, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.iOS), true, false, OnInspectorGUI_Override_iOS, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.tvOS), true, false, OnInspectorGUI_Override_tvOS, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.WindowsUWP), true, false, OnInspectorGUI_Override_WindowsUWP, this, platformColor, _platformSections)); _platformSections.Add(new AnimCollapseSection(GetPlatformButtonContent(Platform.WebGL), true, false, OnInspectorGUI_Override_WebGL, this, platformColor, _platformSections)); _sectionDevModeState = new AnimCollapseSection("State", false, false, OnInspectorGUI_DevMode_State, this, Color.white); _sectionDevModeTexture = new AnimCollapseSection("Texture", false, false, OnInspectorGUI_DevMode_Texture, this, Color.white); _sectionDevModePlaybackQuality = new AnimCollapseSection("Presentation Quality", false, false, OnInspectorGUI_DevMode_PresentationQuality, this, Color.white); _sectionDevModeHapNotchLCDecoder = new AnimCollapseSection("Hap/NotchLC Decoder", false, false, OnInspectorGUI_DevMode_HapNotchLCDecoder, this, Color.white); _sectionDevModeBufferedFrames = new AnimCollapseSection("Buffers", false, false, OnInspectorGUI_DevMode_BufferedFrames, this, Color.white); }
private void CreateStyles() { if (_styleSectionBox == null) { _styleSectionBox = new GUIStyle(GUI.skin.box); if (!EditorGUIUtility.isProSkin) { _styleSectionBox = new GUIStyle(GUI.skin.box); //_styleSectionBox.normal.background = Texture2D.redTexture; } } _iconPlayButton = EditorGUIUtility.IconContent("d_PlayButton"); _iconPauseButton = EditorGUIUtility.IconContent("d_PauseButton"); _iconSceneViewAudio = EditorGUIUtility.IconContent("d_SceneViewAudio"); _iconProject = EditorGUIUtility.IconContent("d_Project"); _iconRotateTool = EditorGUIUtility.IconContent("d_RotateTool"); AnimCollapseSection.CreateStyles(); }
internal static void Show(AnimCollapseSection section, int indentLevel = 0) { if (section.ShowOnlyInEditMode && Application.isPlaying) { return; } float headerGlow = Mathf.Lerp(0.5f, 0.85f, section.Faded); //float headerGlow = Mathf.Lerp(0.85f, 1f, section.Faded); if (EditorGUIUtility.isProSkin) { GUI.backgroundColor = section.BackgroundColor * new Color(headerGlow, headerGlow, headerGlow, 1f); } else { headerGlow = Mathf.Lerp(0.75f, 1f, section.Faded); GUI.backgroundColor = section.BackgroundColor * new Color(headerGlow, headerGlow, headerGlow, 1f); } GUILayout.BeginVertical(_styleHelpBoxNoPad); GUILayout.Box(GUIContent.none, EditorStyles.miniButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; Rect buttonRect = GUILayoutUtility.GetLastRect(); if (Event.current.type != EventType.Layout) { buttonRect.xMin += indentLevel * EditorGUIUtility.fieldWidth / 3f; EditorGUI.indentLevel++; EditorGUIUtility.SetIconSize(new Vector2(16f, 16f)); section.IsExpanded = EditorGUI.Foldout(buttonRect, section.IsExpanded, section.Label, true, _styleButtonFoldout); EditorGUIUtility.SetIconSize(Vector2.zero); EditorGUI.indentLevel--; } if (EditorGUILayout.BeginFadeGroup(section.Faded)) { section.Invoke(); } EditorGUILayout.EndFadeGroup(); GUILayout.EndVertical(); }
public override void OnInspectorGUI() { MediaPlayer media = (this.target) as MediaPlayer; // NOTE: It is important that serializedObject.Update() is called before media.EditorUpdate() // as otherwise the serializedPropertys are not correctly detected as modified serializedObject.Update(); #if AVPROVIDEO_SUPPORT_LIVEEDITMODE bool isPlayingInEditor = false; // Update only during the layout event so that nothing updates for the render event if (!Application.isPlaying && Event.current.type == EventType.Layout) { isPlayingInEditor = media.EditorUpdate(); } #endif if (media == null || _propMediaPath == null) { return; } CreateStyles(); _icon = GetIcon(_icon); ShowImportantMessages(); if (media != null) { OnInspectorGUI_Player(media, media.TextureProducer); } AnimCollapseSection.Show(_sectionMediaInfo); if (_allowDeveloperMode) { AnimCollapseSection.Show(_sectionDebug); } AnimCollapseSection.Show(_sectionSettings); if (serializedObject.ApplyModifiedProperties()) { EditorUtility.SetDirty(target); } AnimCollapseSection.Show(_sectionAboutHelp); #if AVPROVIDEO_SUPPORT_LIVEEDITMODE if (isPlayingInEditor) { GL.InvalidateState(); // NOTE: there seems to be a bug in Unity (2019.3.13) where if you don't have // GL.sRGBWrite = true and then call RepaintAllViews() it makes the current Inspector // background turn black. This only happens when using D3D12 // UPDATE: this is happening in Unity 2019.4.15 as well, and in D3D11 mode. It only // happens when loading a video via the Recent Menu. bool originalSRGBWrite = GL.sRGBWrite; GL.sRGBWrite = true; //this.Repaint(); UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); GL.sRGBWrite = originalSRGBWrite; } // TODO: OnDisable - stop the video if it's playing (and unload it?) #endif }
private void OnInspectorGUI_HttpHeaders(SerializedProperty httpHeadersProp) { if (httpHeadersProp == null) { return; } //GUILayout.Space(8f); bool isExpanded = _HTTPHeadersToggle; if (isExpanded) { EditorGUILayout.BeginVertical(GUI.skin.box); } bool hasHeaders = (httpHeadersProp.arraySize > 0); Color tintColor = hasHeaders?Color.yellow:Color.white; if (AnimCollapseSection.BeginShow("Custom HTTP Headers", ref _HTTPHeadersToggle, tintColor)) { { if (httpHeadersProp.arraySize > 0) { int deleteIndex = -1; for (int i = 0; i < httpHeadersProp.arraySize; ++i) { SerializedProperty httpHeaderProp = httpHeadersProp.GetArrayElementAtIndex(i); SerializedProperty headerProp = httpHeaderProp.FindPropertyRelative("name"); GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); GUI.color = HttpHeader.IsValid(headerProp.stringValue)?Color.white:Color.red; EditorGUILayout.PropertyField(headerProp, GUIContent.none); headerProp.stringValue = headerProp.stringValue.Trim(); GUI.color = Color.white; if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { deleteIndex = i; } GUILayout.EndHorizontal(); SerializedProperty valueProp = httpHeaderProp.FindPropertyRelative("value"); GUI.color = HttpHeader.IsValid(valueProp.stringValue)?Color.white:Color.red; valueProp.stringValue = EditorGUILayout.TextArea(valueProp.stringValue, EditorHelper.IMGUI.GetWordWrappedTextAreaStyle()); GUI.color = Color.white; valueProp.stringValue = valueProp.stringValue.Trim(); GUILayout.EndVertical(); GUILayout.Space(4f); } if (deleteIndex >= 0) { httpHeadersProp.DeleteArrayElementAtIndex(deleteIndex); } } if (GUILayout.Button("+")) { httpHeadersProp.InsertArrayElementAtIndex(httpHeadersProp.arraySize); } } } AnimCollapseSection.EndShow(); if (isExpanded) { EditorGUILayout.EndVertical(); } //GUILayout.Space(8f); }