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");
            }
        }
 private void OnInspectorGUI_Settings()
 {
     foreach (AnimCollapseSection section in _settingSections)
     {
         AnimCollapseSection.Show(section, indentLevel: 1);
     }
 }
Ejemplo n.º 3
0
 private void OnInspectorGUI_PlatformOverrides()
 {
     foreach (AnimCollapseSection section in _platformSections)
     {
         AnimCollapseSection.Show(section, indentLevel: 2);
     }
 }
        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
        }