Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var umpEditor   = (UniversalMediaPlayer)target;
        var umpSettings = UMPSettings.GetSettings();

        EditorGUI.BeginChangeCheck();

        _cachedFontStyle     = EditorStyles.label.fontStyle;
        _cachedTextColor     = EditorStyles.textField.normal.textColor;
        _cachedLabelWordWrap = EditorStyles.label.wordWrap;

        #region Rendering Field
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(_renderingObjectsProp, new GUIContent("Rendering GameObjects:"), true);
        #endregion

        #region Path Field
        EditorGUILayout.Space();

        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Path to video file:");
        EditorStyles.label.fontStyle    = _cachedFontStyle;
        EditorStyles.textField.wordWrap = true;
        _pathProp.stringValue           = EditorGUILayout.TextField(_pathProp.stringValue, GUILayout.Height(30));
        EditorStyles.textField.wordWrap = false;
        #endregion

        #region Additional Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Additional properties:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginVertical("Box");
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("AutoPlay:", GUILayout.MinWidth(60));
        _autoPlayProp.boolValue = EditorGUILayout.Toggle(_autoPlayProp.boolValue, EditorStyles.radioButton);

        if (!_loopSmoothProp.boolValue)
        {
            EditorGUILayout.LabelField("Loop:", GUILayout.MinWidth(36));
        }
        else
        {
            EditorGUILayout.LabelField("Loop(smooth):", GUILayout.MinWidth(90));
        }

        _loopProp.boolValue = EditorGUILayout.Toggle(_loopProp.boolValue, EditorStyles.radioButton, GUILayout.MaxWidth(20));
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        _loopSmoothProp.boolValue = EditorGUILayout.Toggle(_loopSmoothProp.boolValue, EditorStyles.radioButton);
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.LabelField("Mute:", GUILayout.MinWidth(36));
        _muteProp.boolValue = EditorGUILayout.Toggle(_muteProp.boolValue, EditorStyles.radioButton);
        GUILayout.EndHorizontal();

        if (_toggleButton == null)
        {
            _toggleButton = new GUIStyle(EditorStyles.miniButtonMid);
            _toggleButton.normal.background = EditorStyles.miniButton.active.background;
        }

        if (GUILayout.Button("Advanced options", _useAdvancedProp.boolValue ? _toggleButton : EditorStyles.miniButtonMid))
        {
            _useAdvancedProp.boolValue = !_useAdvancedProp.boolValue;
            _availablePlatforms        = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Desktop | UMPSettings.Mobile);
        }

        if (_useAdvancedProp.boolValue)
        {
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            _cachedLabelWidth           = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 170;

            _useFixedSizeProp.boolValue = EditorGUILayout.Toggle("Use fixed video size:", _useFixedSizeProp.boolValue);

            if (_useFixedSizeProp.boolValue)
            {
                _fixedVideoWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Width: ", "Fixed video width."), _fixedVideoWidthProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video width."));
                _fixedVideoWidthProp.intValue = Mathf.Clamp(_fixedVideoWidthProp.intValue, 1, 7680);

                _fixedVideoHeightProp.intValue = EditorGUILayout.IntField(new GUIContent("Height: ", "Fixed video height."), _fixedVideoHeightProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video height."));
                _fixedVideoHeightProp.intValue = Mathf.Clamp(_fixedVideoHeightProp.intValue, 1, 7680);
            }
            else
            {
                _fixedVideoWidthProp.intValue  = 0;
                _fixedVideoHeightProp.intValue = 0;
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();

            if (_availablePlatforms == null || _availablePlatforms.Length <= 0)
            {
                _availablePlatforms = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Desktop | UMPSettings.Mobile);
            }

            if (_availablePlatforms.Length <= 0)
            {
                var warningLabel = new GUIStyle(EditorStyles.textArea);
                warningLabel.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("Can't find 'UniversalMediaPlayer' asset folder, please check your Unity UMP preferences.", warningLabel);

                EditorStyles.label.normal.textColor = _cachedTextColor;
                EditorStyles.label.fontStyle        = _cachedFontStyle;

                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                return;
            }

            _chosenPlatformProp.intValue = GUILayout.SelectionGrid(_chosenPlatformProp.intValue, _availablePlatforms, _availablePlatforms.Length, EditorStyles.miniButton);
            _chosenPlatformProp.intValue = Mathf.Clamp(_chosenPlatformProp.intValue, 0, _availablePlatforms.Length - 1);

            #region Desktop Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.DESKTOP_CATEGORY_NAME)
            {
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                #region Audio Option
                GUILayout.BeginHorizontal();
                GUILayout.Space(13);
                EditorGUILayout.PropertyField(_desktopAudioOutputsProp, new GUIContent("Audio Outputs:"), true);
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                #endregion

                #region Decoding Options
                EditorGUILayout.PropertyField(_desktopHardwareDecodingProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false);

                if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Default)
                {
                    var hardwareDecodingName = "DirectX Video Acceleration (DXVA) 2.0";
                    if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
                    {
                        hardwareDecodingName = "Video Decode Acceleration Framework (VDA)";
                    }
                    if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux)
                    {
                        hardwareDecodingName = "VA-API video decoder via DRM";
                    }

                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", hardwareDecodingName));
                }

                if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Enable)
                {
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic"));
                }
                EditorGUILayout.Space();
                #endregion

                #region Flip Options
                _desktopFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _desktopFlipVerticallyProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost)."));
                #endregion

                #region Buffer Options
                _desktopVideoBufferSizeProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Video Buffer Size: ", "To gain video resolution will be used special video buffer instead of size of video gotted directly from library."), _desktopVideoBufferSizeProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "To gain video resolution will be used special video buffer instead of size of video gotted directly from library."));
                #endregion

                #region Dublicate Options
                _desktopOutputToFileProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Data to a file: ", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."), _desktopOutputToFileProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."));

                if (_desktopOutputToFileProp.boolValue)
                {
                    _desktopDisplayOutputProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Display source video: ", "Display source video when duplicate data to a file."), _desktopDisplayOutputProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Display source video when duplicate data to a file."));

                    _desktopOutputFilePathProp.stringValue = EditorGUILayout.TextField(new GUIContent("Path to file: ", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."), _desktopOutputFilePathProp.stringValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."));
                }
                EditorGUILayout.Space();
                #endregion

                #region RTP/RTSP/SDP Options
                _desktopRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _desktopRtspOverTcpProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                #endregion
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(umpEditor.IsReady);
                #region Caching Options
                _desktopFileCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _desktopFileCachingProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds."));
                _desktopFileCachingProp.intValue = Mathf.Clamp(_desktopFileCachingProp.intValue, 0, 60000);

                _desktopLiveCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _desktopLiveCachingProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds."));
                _desktopLiveCachingProp.intValue = Mathf.Clamp(_desktopLiveCachingProp.intValue, 0, 60000);

                _desktopDiskCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _desktopDiskCachingProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds."));
                _desktopDiskCachingProp.intValue = Mathf.Clamp(_desktopDiskCachingProp.intValue, 0, 60000);

                _desktopNetworkCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _desktopNetworkCachingProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds."));
                _desktopNetworkCachingProp.intValue = Mathf.Clamp(_desktopNetworkCachingProp.intValue, 0, 60000);
                #endregion
                EditorGUI.EndDisabledGroup();
            }
            #endregion

            #region WebGL Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.WebGL.ToString())
            {
                var warningLabel = new GUIStyle(EditorStyles.textArea);
                warningLabel.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("Doesn't support any additional options for current platform in this version.", warningLabel);
            }
            #endregion

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            #region Android Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.Android.ToString())
            {
                #region Player Type Options
                EditorGUILayout.Space();

                var playersNames  = new List <string>();
                var playerValues  = (int[])Enum.GetValues(typeof(PlayerOptionsAndroid.PlayerTypes));
                var playerEnum    = (PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue;
                var choosedPlayer = -1;

                for (int i = 0; i < playerValues.Length; i++)
                {
                    var playerType = (PlayerOptionsAndroid.PlayerTypes)playerValues[i];
                    if ((umpSettings.PlayersAndroid & playerType) == playerType)
                    {
                        playersNames.Add(playerType.ToString());

                        if (playerEnum == playerType)
                        {
                            choosedPlayer = playersNames.Count - 1;
                        }
                    }
                }

                if (choosedPlayer < 0)
                {
                    choosedPlayer = 0;
                }

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80));
                EditorGUILayout.Space();
                choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60));
                GUILayout.EndHorizontal();

                _androidPlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsAndroid.PlayerTypes), playersNames[choosedPlayer]);
                _androidPlayerTypeProp.serializedObject.ApplyModifiedProperties();
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                #endregion

                if (_androidPlayerTypeProp.intValue == (int)PlayerOptionsAndroid.PlayerTypes.LibVLC)
                {
                    #region Hardware Acceleration Options
                    EditorGUILayout.PropertyField(_androidHardwareAccelerationProp, new GUIContent("Hardware Acceleration: ", "This allows hardware acceleration when available:\n* Disabled: better stability.\n* Decoding: may improve performance.\n* Full: may improve performance further."), false);
                    if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.Disabled)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Disabled: better stability."));
                    }

                    if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.DecodingAcceleration)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Decoding: may improve performance."));
                    }

                    if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.FullAcceleration)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full: may improve performance further."));
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region OpenGL Decoding Options
                    EditorGUILayout.PropertyField(_androidOpenGLDecodingProp, new GUIContent("OpenGL Decoding: ", "OpenGL ES2 is used for software decoding and hardware decoding when needed (360° videos), but can affect on correct video rendering."), false);
                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Default)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic."));
                    }

                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Disable)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force Off."));
                    }

                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Enable)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force On."));
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region Video Chroma Options
                    EditorGUILayout.PropertyField(_androidVideoChromaProp, new GUIContent("Force video chroma: ", "* RGB 32-bit: default chroma\n* RGB 16-bit: better performance but lower quality\n* YUV: best performance but does not work on all devices. Android 2.3 and later only."), false);
                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB32Bit)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 32-bit: default chroma."));
                    }

                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB16Bit)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 16-bit: better performance but lower quality."));
                    }

                    if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.YUV)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "YUV: best performance but does not work on all devices. Android 2.3 and later only."));
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region Background Options
                    _androidPlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _androidPlayInBackgroundProb.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
                    #endregion

                    #region RTP/RTSP/SDP Options
                    _androidRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _androidRtspOverTcpProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                    #endregion

                    #region Caching Options
                    _androidNetworkCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "The amount of time to buffer network media (in ms). Does not work with hardware decoding. Leave '0' to reset."), _androidNetworkCachingProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "The amount of time to buffer network media (in ms). Does not work with hardware decoding. Leave '0' to reset."));
                    _androidNetworkCachingProp.intValue = Mathf.Clamp(_androidNetworkCachingProp.intValue, 0, 60000);
                    #endregion
                }
                else
                {
                    var warningLabel = new GUIStyle(EditorStyles.textArea);
                    warningLabel.fontStyle = FontStyle.Bold;
                    EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel);
                }
            }
            #endregion
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            #region IPhone Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.iOS.ToString())
            {
                #region Player Type Options
                EditorGUILayout.Space();

                var playersNames  = new List <string>();
                var playerValues  = (int[])Enum.GetValues(typeof(PlayerOptionsIPhone.PlayerTypes));
                var playerEnum    = (PlayerOptionsIPhone.PlayerTypes)_iphonePlayerTypeProp.intValue;
                var choosedPlayer = -1;

                for (int i = 0; i < playerValues.Length; i++)
                {
                    var playerType = (PlayerOptionsIPhone.PlayerTypes)playerValues[i];
                    if ((umpSettings.PlayersIPhone & playerType) == playerType)
                    {
                        playersNames.Add(playerType.ToString());

                        if (playerEnum == playerType)
                        {
                            choosedPlayer = playersNames.Count - 1;
                        }
                    }
                }

                if (choosedPlayer < 0)
                {
                    choosedPlayer = 0;
                }

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80));
                EditorGUILayout.Space();
                choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60));
                GUILayout.EndHorizontal();

                _iphonePlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsIPhone.PlayerTypes), playersNames[choosedPlayer]);
                _iphonePlayerTypeProp.serializedObject.ApplyModifiedProperties();
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                #endregion

                if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.FFmpeg)
                {
                    #region VideoToolbox Options
                    _iphoneVideoToolboxProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Hardware decoding: ", "This allows hardware decoding when available (enable VideoToolbox decoding)."), _iphoneVideoToolboxProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "This allows hardware decoding when available (enable VideoToolbox decoding)."));

                    if (_iphoneVideoToolboxProp.boolValue)
                    {
                        _iphoneVideoToolboxMaxFrameWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Max width of output frame: ", "Max possible video resolution for hardware decoding."), _iphoneVideoToolboxMaxFrameWidthProp.intValue);
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max possible video resolution for hardware decoding."));
                        _iphoneVideoToolboxMaxFrameWidthProp.intValue = Mathf.Clamp(_iphoneVideoToolboxMaxFrameWidthProp.intValue, 0, 32768);

                        _iphoneVideoToolboxAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Async decompression: ", "Use asynchronous decompression for hardware frame decoding."), _iphoneVideoToolboxAsyncProp.boolValue);
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use asynchronous decompression for hardware frame decoding."));

                        if (_iphoneVideoToolboxAsyncProp.boolValue)
                        {
                            _iphoneVideoToolboxWaitAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Wait for asynchronous frames: ", "Wait when frames is ready."), _iphoneVideoToolboxWaitAsyncProp.boolValue);
                            GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Wait when frames is ready."));
                        }
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region Background Options
                    _iphonePlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _iphonePlayInBackgroundProb.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
                    #endregion

                    #region RTP/RTSP/SDP Options
                    _iphoneRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _iphoneRtspOverTcpProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                    #endregion

                    #region Buffer Options
                    _iphonePacketBufferingProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Packet buffering: ", "Pause output until enough packets have been read after stalling."), _iphonePacketBufferingProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Pause output until enough packets have been read after stalling."));

                    _iphoneMaxBufferSizeProp.intValue = EditorGUILayout.IntField(new GUIContent("Max buffer size: ", "Max buffer size should be pre-read (in bytes)."), _iphoneMaxBufferSizeProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max buffer size should be pre-read."));
                    _iphoneMaxBufferSizeProp.intValue = Mathf.Clamp(_iphoneMaxBufferSizeProp.intValue, 0, 15 * 1024 * 1024);

                    _iphoneMinFramesProp.intValue = EditorGUILayout.IntField(new GUIContent("Min frames: ", "Minimal frames to stop pre-reading."), _iphoneMinFramesProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Minimal frames to stop pre-reading."));
                    _iphoneMinFramesProp.intValue = Mathf.Clamp(_iphoneMinFramesProp.intValue, 5, 50000);

                    _iphoneInfbufProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Infbuf: ", "Don't limit the input buffer size (useful with realtime streams)."), _iphoneInfbufProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Don't limit the input buffer size (useful with realtime streams)."));

                    EditorGUILayout.Space();
                    #endregion

                    #region Frame Options
                    _iphoneFramedropProp.intValue = EditorGUILayout.IntField(new GUIContent("Framedrop: ", "Drop frames when cpu is too slow."), _iphoneFramedropProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames when cpu is too slow."));
                    _iphoneFramedropProp.intValue = Mathf.Clamp(_iphoneFramedropProp.intValue, -1, 120);

                    _iphoneMaxFpsProp.intValue = EditorGUILayout.IntField(new GUIContent("Max fps: ", "Drop frames in video whose fps is greater than max-fps."), _iphoneMaxFpsProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames in video whose fps is greater than max-fps."));
                    _iphoneMaxFpsProp.intValue = Mathf.Clamp(_iphoneMaxFpsProp.intValue, -1, 120);
                    #endregion
                }
                else if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.Native)
                {
                    #region Flip Options
                    _iphoneFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _iphoneFlipVerticallyProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost)."));
                    #endregion
                }
                else
                {
                    var warningLabel = new GUIStyle(EditorStyles.textArea);
                    warningLabel.fontStyle = FontStyle.Bold;
                    EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_iphonePlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel);
                }
            }
            #endregion
            EditorGUI.EndDisabledGroup();

            EditorGUIUtility.labelWidth = _cachedLabelWidth;
        }
        else
        {
            _desktopFileCachingProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _desktopLiveCachingProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _desktopDiskCachingProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _desktopNetworkCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
            _fixedVideoWidthProp.intValue       = -1;
            _fixedVideoHeightProp.intValue      = -1;
        }

        if (UMPSettings.GetSettings().UseExternalLibs)
        {
            if (_externalPath.Equals(string.Empty))
            {
                _externalPath = UMPSettings.RuntimePlatformLibraryPath(true);
            }

            if (_externalPath != string.Empty)
            {
                var wrapTextStyle = EditorStyles.textArea;
                wrapTextStyle.wordWrap = true;
                EditorGUILayout.LabelField("Path to external/installed libraries: '" + _externalPath + "'", wrapTextStyle);
            }
        }
        else
        {
            _externalPath = string.Empty;
        }

        GUILayout.EndVertical();
        #endregion

        #region Player Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Player properties:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical("Box");

        GUILayout.BeginHorizontal();
        var centeredStyle = GUI.skin.GetStyle("Label");
        centeredStyle.alignment = TextAnchor.MiddleCenter;
        EditorGUILayout.LabelField("Volume", centeredStyle, GUILayout.MinWidth(80));
        if (GUILayout.Button("x", EditorStyles.miniButton))
        {
            _volumeProp.intValue = 50;
        }
        GUILayout.EndHorizontal();

        _volumeProp.intValue = EditorGUILayout.IntSlider(_volumeProp.intValue, 0, 100);
        GUILayout.EndVertical();

        GUILayout.BeginVertical("Box");

        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Play rate", centeredStyle, GUILayout.MinWidth(80));
        if (GUILayout.Button("x", EditorStyles.miniButton))
        {
            _playRateProp.floatValue = 1f;
        }
        GUILayout.EndHorizontal();

        _playRateProp.floatValue = EditorGUILayout.Slider(_playRateProp.floatValue, 0.5f, 5f);
        GUILayout.EndVertical();

        GUILayout.EndHorizontal();

        EditorGUI.BeginDisabledGroup(!umpEditor.IsReady);
        EditorGUILayout.Space();
        GUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Position", centeredStyle, GUILayout.MinWidth(100));
        _positionProp.floatValue = EditorGUILayout.Slider(_positionProp.floatValue, 0f, 1f);
        GUILayout.EndVertical();
        EditorGUI.EndDisabledGroup();

        EditorGUI.BeginDisabledGroup(!Application.isPlaying || !umpEditor.isActiveAndEnabled || umpEditor.IsParsing);
        GUILayout.BeginHorizontal("Box");
        if (GUILayout.Button("LOAD", GUILayout.MinWidth(40)))
        {
            umpEditor.Prepare();
        }
        if (GUILayout.Button("PLAY", GUILayout.MinWidth(40)))
        {
            umpEditor.Play();
        }
        if (GUILayout.Button("PAUSE", GUILayout.MinWidth(40)))
        {
            umpEditor.Pause();
        }
        if (GUILayout.Button("STOP", GUILayout.MinWidth(40)))
        {
            umpEditor.Stop();
        }
        if (GUILayout.Button("SHOT", GUILayout.MinWidth(40)))
        {
            umpEditor.Snapshot(Application.persistentDataPath);
        }
        GUILayout.EndHorizontal();
        EditorGUI.EndDisabledGroup();
        #endregion

        #region Events & Logging Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Events & Logging:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginVertical("Box");
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        EditorGUILayout.PropertyField(_logDetailProp, GUILayout.MinWidth(50));
        EditorGUI.EndDisabledGroup();

        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Last msg: ", GUILayout.MinWidth(70));
        EditorStyles.label.normal.textColor = Color.black;
        EditorStyles.label.fontStyle        = FontStyle.Italic;
        EditorStyles.label.wordWrap         = true;
        EditorGUILayout.LabelField(_lastEventMsgProp.stringValue, GUILayout.MaxWidth(100));
        EditorStyles.label.normal.textColor = _cachedTextColor;
        EditorStyles.label.fontStyle        = _cachedFontStyle;
        EditorStyles.label.wordWrap         = _cachedLabelWordWrap;
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        _showEventsListeners = EditorGUILayout.Foldout(_showEventsListeners, "Event Listeners");

        if (_showEventsListeners)
        {
            EditorGUILayout.PropertyField(_pathPreparedEventProp, new GUIContent("Path Prepared"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_openingEventProp, new GUIContent("Opening"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_bufferingEventProp, new GUIContent("Buffering"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_imageReadyEventProp, new GUIContent("ImageReady"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_preparedEventProp, new GUIContent("Prepared"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_playingEventProp, new GUIContent("Playing"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_pausedEventProp, new GUIContent("Paused"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_stoppedEventProp, new GUIContent("Stopped"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_endReachedEventProp, new GUIContent("End Reached"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_encounteredErrorEventProp, new GUIContent("Encountered Error"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_timeChangedEventProp, new GUIContent("Time Changed"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_positionChangedEventProp, new GUIContent("Position Changed"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_snapshotTakenEventProp, new GUIContent("Snapshot"), true, GUILayout.MinWidth(50));
        }
        #endregion

        EditorStyles.label.normal.textColor = _cachedTextColor;
        EditorStyles.label.fontStyle        = _cachedFontStyle;

        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }
Esempio n. 2
0
    public static void UMPGUI()
    {
        if (!_preloaded)
        {
            _umpSettings = UMPSettings.Instance;
            _preloaded   = true;
        }

        var chachedLabelColor = EditorStyles.label.normal.textColor;
        var cachedFontStyle   = EditorStyles.label.fontStyle;

        _umpSettings.UseCustomAssetPath = EditorGUILayout.Toggle(new GUIContent("Use custom asset path", "Will be using cusstom asset path to main 'UniversalMediaPlayer' folder (give you possibility to move asset folder in different space in your project)."), _umpSettings.UseCustomAssetPath);

        EditorGUILayout.Space();

        EditorGUI.BeginDisabledGroup(!_umpSettings.UseCustomAssetPath);
        EditorStyles.textField.wordWrap = true;
        _umpSettings.AssetPath          = EditorGUILayout.TextField(_umpSettings.AssetPath, GUILayout.Height(30));
        EditorStyles.textField.wordWrap = false;
        EditorGUI.EndDisabledGroup();

        if (!_umpSettings.IsValidAssetPath && _umpSettings.UseCustomAssetPath)
        {
            if (GUILayout.Button("Find asset folder in current project"))
            {
                GUI.FocusControl(null);
                _umpSettings.AssetPath = FindAssetFolder("Assets");
            }
        }

        EditorStyles.label.fontStyle = FontStyle.Italic;
        if (_umpSettings.IsValidAssetPath)
        {
            EditorGUILayout.LabelField("Path is correct.");
        }
        else
        {
            EditorStyles.label.normal.textColor = Color.red;
            if (!_umpSettings.UseCustomAssetPath)
            {
                EditorGUILayout.LabelField("Can't find asset folder, try to use custom asset path.");
            }
            else
            {
                EditorGUILayout.LabelField("Can't find asset folder.");
            }
        }

        EditorStyles.label.normal.textColor = chachedLabelColor;
        EditorStyles.label.fontStyle        = cachedFontStyle;

        EditorGUILayout.LabelField("Editor/Desktop platforms:", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        _umpSettings.UseAudioSource = EditorGUILayout.Toggle(new GUIContent("Use Unity 'Audio Source' component", "Will be using Unity 'Audio Source' component for audio output for all UMP instances (global) by default."), _umpSettings.UseAudioSource);

        EditorGUILayout.Space();

        _umpSettings.UseExternalLibs = EditorGUILayout.Toggle(new GUIContent("Use installed VLC libraries", "Will be using external/installed VLC player libraries for all UMP instances (global). Path to install VLC directory will be obtained automatically (you can also setup your custom path)."), _umpSettings.UseExternalLibs);

        EditorStyles.label.wordWrap         = true;
        EditorStyles.label.normal.textColor = Color.red;

        bool   useExternal   = true;
        string librariesPath = UMPSettings.RuntimePlatformLibraryPath(false);

        if (!string.IsNullOrEmpty(librariesPath) && Directory.Exists(librariesPath))
        {
            string[] libraries = Directory.GetFiles(librariesPath);
            int      includes  = 0;

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.dll.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.dll.meta") ||
                        Path.GetFileName(library).Contains("plugins.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 3)
                {
                    useExternal = false;
                }
            }

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.dylib.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.dylib.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 2)
                {
                    useExternal = false;
                }
            }

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.so.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.so.meta") ||
                        Path.GetFileName(library).Contains("plugins.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 3)
                {
                    useExternal = false;
                }
            }
        }

        if (useExternal)
        {
            EditorGUILayout.LabelField("Please correctly import UMP (Win, Mac, Linux) package to use internal VLC libraries.");
            _umpSettings.UseExternalLibs = true;
        }

        EditorGUILayout.Space();

        if (_umpSettings.UseExternalLibs)
        {
            string externalLibsPath = UMPSettings.RuntimePlatformLibraryPath(true);
            if (externalLibsPath.Equals(string.Empty))
            {
                EditorGUILayout.LabelField("Did you install VLC player software correctly? Please make sure that:");
                EditorGUILayout.LabelField("1. Your installed VLC player bit application == Unity Editor bit application (VLC player 64-bit == Unity 64-bit Editor);");
                EditorGUILayout.LabelField("2. Use last version installer from official site: ");

                if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win)
                {
                    EditorGUILayout.LabelField("Windows platform: ");

                    var link86 = "http://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link86 + " (Editor x86)");

                    Rect linkRect86 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect86.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link86);
                    }

                    var link64 = "http://get.videolan.org/vlc/2.2.4/win64/vlc-2.2.4-win64.exe";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link64 + " (Editor x64)");

                    Rect linkRect64 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link64);
                    }
                }

                if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
                {
                    EditorGUILayout.LabelField("Mac OS platform: ");

                    var link64 = "http://get.videolan.org/vlc/2.2.4/macosx/vlc-2.2.4.dmg";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link64 + " (Editor x64)");

                    Rect linkRect64 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link64);
                    }
                }

                EditorStyles.label.normal.textColor = Color.red;
                EditorGUILayout.LabelField("Or you can try to use custom additional path to your VLC libraries.");

                EditorGUILayout.Space();
            }

            EditorStyles.label.normal.textColor = chachedLabelColor;

            EditorGUILayout.LabelField(new GUIContent("External/installed VLC libraries path:", "Default path to installed VLC player libraries. Example: '" + @"C:\Program Files\VideoLAN\VLC'."));
            GUIStyle pathLabel = EditorStyles.textField;
            pathLabel.wordWrap = true;
            EditorGUILayout.LabelField(externalLibsPath, pathLabel);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Additional external/installed VLC libraries path:", "Additional path to installed VLC player libraries. Will be used if path to libraries can't be automatically obtained. Example: '" + @"C:\Program Files\VideoLAN\VLC'."));
            GUIStyle additionalLabel = EditorStyles.textField;
            additionalLabel.wordWrap = true;

            _umpSettings.AdditionalLibsPath = EditorGUILayout.TextField(_umpSettings.AdditionalLibsPath);
        }

        EditorStyles.label.normal.textColor = chachedLabelColor;

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Mobile platforms:", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        _umpSettings.UseAndroidNative = EditorGUILayout.Toggle(new GUIContent("Use Android native player", "Will be using Android native media player (MediaPlayer) for all UMP instances (global)."), _umpSettings.UseAndroidNative);

        if (_nativeAndroidLibraryPrepare != _umpSettings.UseAndroidNative)
        {
            List <string> libs = new List <string>();
            libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/Android/libs/armeabi-v7a"));
            libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/Android/libs/x86"));

            foreach (var lib in libs)
            {
                if (lib.Contains(".meta") && !lib.Contains("libUniversalMediaPlayer"))
                {
                    File.SetAttributes(lib, FileAttributes.Normal);
                    string metaData = File.ReadAllText(lib);
                    var    match    = Regex.Match(metaData, @"Android.*\s*enabled:.");

                    if (match.Success)
                    {
                        metaData = Regex.Replace(metaData, @"Android.*\s*enabled:." + (!_nativeAndroidLibraryPrepare ? 1 : 0), match.Value + (_nativeAndroidLibraryPrepare ? 1 : 0));
                        File.WriteAllText(lib, metaData);
                    }
                }
            }
            libs.Clear();
            AssetDatabase.Refresh();
        }

        _nativeAndroidLibraryPrepare = _umpSettings.UseAndroidNative;

        EditorGUILayout.Space();

        _umpSettings.UseIPhoneNative = EditorGUILayout.Toggle(new GUIContent("Use iOS native player", "Will be using iOS native media player (AVPlayer) for all UMP instances (global)."), _umpSettings.UseIPhoneNative);

        if (_nativeIPhoneLibraryPrepare != _umpSettings.UseIPhoneNative)
        {
            List <string> libs = new List <string>();
            libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/iOS"));

            foreach (var lib in libs)
            {
                if (lib.Contains(".meta"))
                {
                    if (!Path.GetFileNameWithoutExtension(lib).Contains("Base"))
                    {
                        File.SetAttributes(lib, FileAttributes.Normal);
                        string metaData = File.ReadAllText(lib);
                        var    match    = Regex.Match(metaData, @"iOS.*\s*enabled:.");

                        if (match.Success)
                        {
                            var isFFmpeg = (lib.Contains("FFmpeg") || lib.Contains("framework"));
                            var enable   = isFFmpeg ? !_umpSettings.UseIPhoneNative : _umpSettings.UseIPhoneNative;
                            metaData = Regex.Replace(metaData, @"iOS.*\s*enabled:." + (!enable ? 1 : 0), match.Value + (enable ? 1 : 0));
                            File.WriteAllText(lib, metaData);
                        }
                    }
                }
            }
            libs.Clear();
            AssetDatabase.Refresh();
        }

        _nativeIPhoneLibraryPrepare = _umpSettings.UseIPhoneNative;
    }
Esempio n. 3
0
    public static void UMPGUI()
    {
        var umpSettings      = UMPSettings.GetSettings();
        var cachedFontStyle  = EditorStyles.label.fontStyle;
        var cachedLabelColor = EditorStyles.label.normal.textColor;
        var cachedLabelWidth = EditorGUIUtility.labelWidth;

        var installedMobilePlatforms = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Mobile);

        if (_buttonStyleToggled == null)
        {
            _buttonStyleToggled = new GUIStyle(EditorStyles.miniButton);
            _buttonStyleToggled.normal.background = _buttonStyleToggled.active.background;
        }

        if (playersAndroid == null)
        {
            playersAndroid = new bool[Enum.GetNames(typeof(PlayerOptionsAndroid.PlayerTypes)).Length];
            for (int i = 0; i < playersAndroid.Length; i++)
            {
                var playerType = (PlayerOptionsAndroid.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0));
                if ((umpSettings.PlayersAndroid & playerType) == playerType)
                {
                    playersAndroid[i] = true;
                }
            }
        }

        if (playersIPhone == null)
        {
            playersIPhone = new bool[Enum.GetNames(typeof(PlayerOptionsIPhone.PlayerTypes)).Length];
            for (int i = 0; i < playersIPhone.Length; i++)
            {
                var playerType = (PlayerOptionsIPhone.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0));
                if ((umpSettings.PlayersIPhone & playerType) == playerType)
                {
                    playersIPhone[i] = true;
                }
            }
        }

        umpSettings.UseCustomAssetPath = EditorGUILayout.Toggle(new GUIContent("Use custom asset path", "Will be using cusstom asset path to main 'UniversalMediaPlayer' folder (give you possibility to move asset folder in different space in your project)."), umpSettings.UseCustomAssetPath);

        EditorGUILayout.Space();

        EditorGUI.BeginDisabledGroup(!umpSettings.UseCustomAssetPath);
        EditorStyles.textField.wordWrap = true;
        umpSettings.AssetPath           = EditorGUILayout.TextField(umpSettings.AssetPath, GUILayout.Height(30));
        EditorStyles.textField.wordWrap = false;
        EditorGUI.EndDisabledGroup();

        if (!umpSettings.IsValidAssetPath && umpSettings.UseCustomAssetPath)
        {
            if (GUILayout.Button("Find asset folder in current project"))
            {
                GUI.FocusControl(null);
                umpSettings.AssetPath = FindAssetFolder("Assets");
            }
        }

        EditorStyles.label.fontStyle = FontStyle.Italic;
        if (umpSettings.IsValidAssetPath)
        {
            EditorGUILayout.LabelField("Path is correct.");
        }
        else
        {
            EditorStyles.label.normal.textColor = Color.red;
            if (!umpSettings.UseCustomAssetPath)
            {
                EditorGUILayout.LabelField("Can't find asset folder, try to use custom asset path.");
            }
            else
            {
                EditorGUILayout.LabelField("Can't find asset folder.");
            }
        }

        EditorStyles.label.normal.textColor = cachedLabelColor;
        EditorStyles.label.fontStyle        = cachedFontStyle;

        EditorGUILayout.LabelField("Editor/Desktop platforms:", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        umpSettings.UseAudioSource = EditorGUILayout.Toggle(new GUIContent("Use Unity 'Audio Source' component", "Will be using Unity 'Audio Source' component for audio output for all UMP instances (global) by default."), umpSettings.UseAudioSource);

        EditorGUILayout.Space();

        umpSettings.UseExternalLibs = EditorGUILayout.Toggle(new GUIContent("Use installed VLC libraries", "Will be using external/installed VLC player libraries for all UMP instances (global). Path to install VLC directory will be obtained automatically (you can also setup your custom path)."), umpSettings.UseExternalLibs);

        EditorStyles.label.wordWrap         = true;
        EditorStyles.label.normal.textColor = Color.red;

        bool   useExternal   = true;
        string librariesPath = UMPSettings.RuntimePlatformLibraryPath(false);

        if (!string.IsNullOrEmpty(librariesPath) && Directory.Exists(librariesPath))
        {
            string[] libraries = Directory.GetFiles(librariesPath);
            int      includes  = 0;

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.dll.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.dll.meta") ||
                        Path.GetFileName(library).Contains("plugins.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 3)
                {
                    useExternal = false;
                }
            }

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.dylib.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.dylib.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 2)
                {
                    useExternal = false;
                }
            }

            if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux)
            {
                foreach (var library in libraries)
                {
                    if (Path.GetFileName(library).Contains("libvlc.so.meta") ||
                        Path.GetFileName(library).Contains("libvlccore.so.meta") ||
                        Path.GetFileName(library).Contains("plugins.meta"))
                    {
                        includes++;
                    }
                }

                if (includes >= 3)
                {
                    useExternal = false;
                }
            }
        }

        if (useExternal)
        {
            EditorGUILayout.LabelField("Please correctly import UMP (Win, Mac, Linux) package to use internal VLC libraries.");
            umpSettings.UseExternalLibs = true;
        }

        EditorGUILayout.Space();

        if (umpSettings.UseExternalLibs)
        {
            string externalLibsPath = UMPSettings.RuntimePlatformLibraryPath(true);
            if (externalLibsPath.Equals(string.Empty))
            {
                EditorGUILayout.LabelField("Did you install VLC player software correctly? Please make sure that:");
                EditorGUILayout.LabelField("1. Your installed VLC player bit application == Unity Editor bit application (VLC player 64-bit == Unity 64-bit Editor);");
                EditorGUILayout.LabelField("2. Use last version installer from official site: ");

                if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win)
                {
                    EditorGUILayout.LabelField("Windows platform: ");

                    var link86 = "http://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link86 + " (Editor x86)");

                    Rect linkRect86 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect86.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link86);
                    }

                    var link64 = "http://get.videolan.org/vlc/2.2.4/win64/vlc-2.2.4-win64.exe";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link64 + " (Editor x64)");

                    Rect linkRect64 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link64);
                    }
                }

                if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
                {
                    EditorGUILayout.LabelField("Mac OS platform: ");

                    var link64 = "http://get.videolan.org/vlc/2.2.4/macosx/vlc-2.2.4.dmg";
                    EditorStyles.label.normal.textColor = Color.blue;
                    EditorGUILayout.LabelField(link64 + " (Editor x64)");

                    Rect linkRect64 = GUILayoutUtility.GetLastRect();

                    if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition))
                    {
                        Application.OpenURL(link64);
                    }
                }

                EditorStyles.label.normal.textColor = Color.red;
                EditorGUILayout.LabelField("Or you can try to use custom additional path to your VLC libraries.");

                EditorGUILayout.Space();
            }

            EditorStyles.label.normal.textColor = cachedLabelColor;

            EditorGUILayout.LabelField(new GUIContent("External/installed VLC libraries path:", "Default path to installed VLC player libraries. Example: '" + @"C:\Program Files\VideoLAN\VLC'."));
            GUIStyle pathLabel = EditorStyles.textField;
            pathLabel.wordWrap = true;
            EditorGUILayout.LabelField(externalLibsPath, pathLabel);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Additional external/installed VLC libraries path:", "Additional path to installed VLC player libraries. Will be used if path to libraries can't be automatically obtained. Example: '" + @"C:\Program Files\VideoLAN\VLC'."));
            GUIStyle additionalLabel = EditorStyles.textField;
            additionalLabel.wordWrap = true;

            umpSettings.AdditionalLibsPath = EditorGUILayout.TextField(umpSettings.AdditionalLibsPath);
        }

        EditorStyles.label.normal.textColor = cachedLabelColor;

        if (installedMobilePlatforms.Length > 0)
        {
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Mobile platforms:", EditorStyles.boldLabel);

            EditorGUILayout.Space();

            _chosenMobilePlatform = GUILayout.SelectionGrid(_chosenMobilePlatform, installedMobilePlatforms, installedMobilePlatforms.Length, EditorStyles.miniButton);

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Player Types:", "Choose player types that will be used in your project"));

            if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.Android.ToString())
            {
                for (int i = 0; i < playersAndroid.Length; i++)
                {
                    if (GUILayout.Button(Enum.GetName(typeof(PlayerOptionsAndroid.PlayerTypes), (i * 2) + (i == 0 ? 1 : 0)), playersAndroid[i] ? _buttonStyleToggled : EditorStyles.miniButton))
                    {
                        var playerType = (PlayerOptionsAndroid.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0));

                        if ((umpSettings.PlayersAndroid & ~playerType) > 0)
                        {
                            playersAndroid[i]          = !playersAndroid[i];
                            umpSettings.PlayersAndroid = playersAndroid[i] ? umpSettings.PlayersAndroid | playerType : umpSettings.PlayersAndroid & ~playerType;

                            LibrariesHandler(UMPSettings.Platforms.Android, umpSettings.PlayersAndroid);
                        }
                    }
                }
            }

            if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.iOS.ToString())
            {
                for (int i = 0; i < playersIPhone.Length; i++)
                {
                    if (GUILayout.Button(Enum.GetName(typeof(PlayerOptionsIPhone.PlayerTypes), (i * 2) + (i == 0 ? 1 : 0)), playersIPhone[i] ? _buttonStyleToggled : EditorStyles.miniButton))
                    {
                        var playerType = (PlayerOptionsIPhone.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0));

                        if ((umpSettings.PlayersIPhone & ~playerType) > 0)
                        {
                            playersIPhone[i]          = !playersIPhone[i];
                            umpSettings.PlayersIPhone = playersIPhone[i] ? umpSettings.PlayersIPhone | playerType : umpSettings.PlayersIPhone & ~playerType;

                            LibrariesHandler(UMPSettings.Platforms.iOS, umpSettings.PlayersIPhone);
                        }
                    }
                }
            }

            GUILayout.EndHorizontal();

            if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.Android.ToString())
            {
                GUILayout.BeginVertical("Box");
                _showExportedPaths = EditorGUILayout.Foldout(_showExportedPaths, new GUIContent("Exported Video Paths", "'StreamingAssets' videos (or video parts) that will be copied to special cached destination on device (for possibilities to use playlist: videos that contains many parts)"));

                if (_showExportedPaths)
                {
                    scrollPos            = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(false));
                    _exportedPathsSize   = EditorGUILayout.IntField(new GUIContent("Size", "Amount of exported videos"), umpSettings.AndroidExportedPaths.Length, GUILayout.ExpandWidth(true));
                    _cachedExportedPaths = new string[_exportedPathsSize];

                    if (_exportedPathsSize >= 0)
                    {
                        _cachedExportedPaths = new string[_exportedPathsSize];

                        for (int i = 0; i < umpSettings.AndroidExportedPaths.Length; i++)
                        {
                            if (i < _exportedPathsSize)
                            {
                                _cachedExportedPaths[i] = umpSettings.AndroidExportedPaths[i];
                            }
                        }
                    }

                    EditorGUIUtility.labelWidth = 60;

                    for (int i = 0; i < _cachedExportedPaths.Length; i++)
                    {
                        _cachedExportedPaths[i] = EditorGUILayout.TextField("Path " + i + ":", _cachedExportedPaths[i]);
                    }

                    EditorGUIUtility.labelWidth = cachedLabelWidth;

                    umpSettings.AndroidExportedPaths = _cachedExportedPaths;

                    EditorGUILayout.EndScrollView();

                    var evt = Event.current;

                    switch (evt.type)
                    {
                    case EventType.DragUpdated:
                    case EventType.DragPerform:

                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                        if (evt.type == EventType.DragPerform)
                        {
                            DragAndDrop.AcceptDrag();

                            var filePaths = DragAndDrop.paths;

                            if (filePaths.Length > 0)
                            {
                                var arrayLength = umpSettings.AndroidExportedPaths.Length > filePaths.Length ? umpSettings.AndroidExportedPaths.Length : filePaths.Length;
                                _cachedExportedPaths = new string[arrayLength];

                                for (int i = 0; i < arrayLength; i++)
                                {
                                    if (i < umpSettings.AndroidExportedPaths.Length)
                                    {
                                        _cachedExportedPaths[i] = umpSettings.AndroidExportedPaths[i];
                                    }

                                    if (i < filePaths.Length)
                                    {
                                        _cachedExportedPaths[i] = filePaths[i];
                                    }
                                }

                                umpSettings.AndroidExportedPaths = _cachedExportedPaths;
                            }
                        }
                        break;
                    }
                }
                GUILayout.EndVertical();
            }
        }

        if (UMPSettings.SaveSettings(umpSettings))
        {
            AssetDatabase.Refresh();
        }
    }
Esempio n. 4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var umpEditor = (UniversalMediaPlayer)target;

        EditorGUIUtility.labelWidth = 0;
        EditorGUIUtility.fieldWidth = 0;

        EditorGUI.BeginChangeCheck();

        _cachedFontStyle     = EditorStyles.label.fontStyle;
        _cachedTextColor     = EditorStyles.textField.normal.textColor;
        _cachedLabelWordWrap = EditorStyles.label.wordWrap;

        #region Rendering Field
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(_renderingObjectsProp, new GUIContent("Rendering GameObjects:"), true);
        #endregion

        #region Path Field
        EditorGUILayout.Space();

        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Path to video file:");
        EditorStyles.label.fontStyle    = _cachedFontStyle;
        EditorStyles.textField.wordWrap = true;
        _pathProp.stringValue           = EditorGUILayout.TextField(_pathProp.stringValue, GUILayout.Height(30));
        EditorStyles.textField.wordWrap = false;
        #endregion

        #region Additional Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Additional properties:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginVertical("Box");
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("AutoPlay:", GUILayout.MinWidth(60));
        _autoPlayProp.boolValue = EditorGUILayout.Toggle(_autoPlayProp.boolValue, EditorStyles.radioButton);

        if (!_loopSmoothProp.boolValue)
        {
            EditorGUILayout.LabelField("Loop:", GUILayout.MinWidth(36));
        }
        else
        {
            EditorGUILayout.LabelField("Loop(smooth):", GUILayout.MinWidth(90));
        }

        _loopProp.boolValue = EditorGUILayout.Toggle(_loopProp.boolValue, EditorStyles.radioButton, GUILayout.MaxWidth(20));
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        _loopSmoothProp.boolValue = EditorGUILayout.Toggle(_loopSmoothProp.boolValue, EditorStyles.radioButton);
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.LabelField("Mute:", GUILayout.MinWidth(36));
        _muteProp.boolValue = EditorGUILayout.Toggle(_muteProp.boolValue, EditorStyles.radioButton);
        GUILayout.EndHorizontal();

        if (_toggleButton == null)
        {
            _toggleButton = new GUIStyle(EditorStyles.miniButton);
            _toggleButton.normal.background = EditorStyles.miniButton.active.background;
        }

        if (GUILayout.Button("Advanced options", _useAdvancedProp.boolValue ? _toggleButton : EditorStyles.miniButton))
        {
            _useAdvancedProp.boolValue = !_useAdvancedProp.boolValue;
            _availablePlatforms        = AvailablePlatforms;
        }

        if (_useAdvancedProp.boolValue)
        {
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            _cachedLabelWidth           = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 170;

            _useFixedSizeProp.boolValue = EditorGUILayout.Toggle("Use fixed video size:", _useFixedSizeProp.boolValue);

            if (_useFixedSizeProp.boolValue)
            {
                _fixedVideoWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Width: ", "Fixed video width."), _fixedVideoWidthProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video width."));
                _fixedVideoWidthProp.intValue = Mathf.Clamp(_fixedVideoWidthProp.intValue, 1, 7680);

                _fixedVideoHeightProp.intValue = EditorGUILayout.IntField(new GUIContent("Height: ", "Fixed video height."), _fixedVideoHeightProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video height."));
                _fixedVideoHeightProp.intValue = Mathf.Clamp(_fixedVideoHeightProp.intValue, 1, 7680);
            }
            else
            {
                _fixedVideoWidthProp.intValue  = 0;
                _fixedVideoHeightProp.intValue = 0;
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();

            if (_availablePlatforms == null || _availablePlatforms.Length <= 0)
            {
                _availablePlatforms = AvailablePlatforms;
            }

            if (_availablePlatforms.Length <= 0)
            {
                var warningLabel = new GUIStyle(EditorStyles.textArea);
                warningLabel.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("Can't find 'UniversalMediaPlayer' asset folder, please check your Unity UMP preferences.", warningLabel);

                EditorStyles.label.normal.textColor = _cachedTextColor;
                EditorStyles.label.fontStyle        = _cachedFontStyle;

                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                return;
            }

            _chosenPlatformProp.intValue = GUILayout.SelectionGrid(_chosenPlatformProp.intValue, _availablePlatforms, _availablePlatforms.Length, EditorStyles.miniButton);
            _chosenPlatformProp.intValue = Mathf.Clamp(_chosenPlatformProp.intValue, 0, _availablePlatforms.Length - 1);

            #region Desktop Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == DESKTOP_CATEGORY_NAME)
            {
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                #region Audio Option
                GUILayout.BeginHorizontal();
                GUILayout.Space(13);
                EditorGUILayout.PropertyField(_audioSourcesDesktopProp, new GUIContent("Audio Sources:"), true);
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                #endregion

                #region Decoding Options
                EditorGUILayout.PropertyField(_hardwareDecodingDesktopProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false);

                if (_hardwareDecodingDesktopProp.intValue == (int)PlayerOptions.State.Default)
                {
                    var hardwareDecodingName = "DirectX Video Acceleration (DXVA) 2.0";
                    if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac)
                    {
                        hardwareDecodingName = "Video Decode Acceleration Framework (VDA)";
                    }
                    if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux)
                    {
                        hardwareDecodingName = "VA-API video decoder via DRM";
                    }

                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", hardwareDecodingName));

                    if (UMPSettings.EditorBitMode == UMPSettings.BitModes.x86)
                    {
                        var warningLabel = new GUIStyle(EditorStyles.textArea);
                        warningLabel.fontStyle = FontStyle.Italic;
                        EditorGUILayout.LabelField("Doesn't support on current bit system and will be ignored and swiched to 'Enable' state.", warningLabel);
                    }
                }

                if (_hardwareDecodingDesktopProp.intValue == (int)PlayerOptions.State.Enable)
                {
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic"));
                }
                EditorGUILayout.Space();
                #endregion

                #region Flip Options
                _flipVerticallyDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _flipVerticallyDesktopProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost)."));
                #endregion

                #region Dublicate Options
                _outputToFileDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Data to a file: ", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."), _outputToFileDesktopProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."));

                if (_outputToFileDesktopProp.boolValue)
                {
                    _displayOutputDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Display source video: ", "Display source video when duplicate data to a file."), _displayOutputDesktopProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Display source video when duplicate data to a file."));

                    _outputFilePathDesktopProp.stringValue = EditorGUILayout.TextField(new GUIContent("Path to file: ", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."), _outputFilePathDesktopProp.stringValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."));
                }
                EditorGUILayout.Space();
                #endregion

                #region RTP/RTSP/SDP Options
                _rtspOverTcpDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpDesktopProp.boolValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                #endregion
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(umpEditor.IsReady);
                #region Caching Options
                _fileCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _fileCachingDesktopProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds."));
                _fileCachingDesktopProp.intValue = Mathf.Clamp(_fileCachingDesktopProp.intValue, 0, 60000);

                _liveCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _liveCachingDesktopProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds."));
                _liveCachingDesktopProp.intValue = Mathf.Clamp(_liveCachingDesktopProp.intValue, 0, 60000);

                _diskCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _diskCachingDesktopProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds."));
                _diskCachingDesktopProp.intValue = Mathf.Clamp(_diskCachingDesktopProp.intValue, 0, 60000);

                _networkCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _networkCachingDesktopProp.intValue);
                GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds."));
                _networkCachingDesktopProp.intValue = Mathf.Clamp(_networkCachingDesktopProp.intValue, 0, 60000);
                #endregion
                EditorGUI.EndDisabledGroup();
            }
            #endregion

            #region WebGL Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == WEBGL_CATEGORY_NAME)
            {
                var warningLabel = new GUIStyle(EditorStyles.textArea);
                warningLabel.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("Doesn't support any additional options for current platform in this version.", warningLabel);
            }
            #endregion

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            #region Android Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == ANDROID_CATEGORY_NAME)
            {
                if (!UMPPreference.Instance.UseAndroidNative)
                {
                    #region Decoding Options
                    EditorGUILayout.PropertyField(_hardwareDecodingAndroidProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false);
                    if (_hardwareDecodingAndroidProp.intValue == (int)PlayerOptions.State.Default)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "HW decoder will be used"));
                    }

                    if (_hardwareDecodingAndroidProp.intValue == (int)PlayerOptions.State.Enable)
                    {
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force HW acceleration even for unknown devices"));
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region Background Options
                    _playInBackgroundAndroidProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _playInBackgroundAndroidProb.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
                    #endregion

                    #region RTP/RTSP/SDP Options
                    _rtspOverTcpAndroidProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpAndroidProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                    #endregion

                    #region Caching Options
                    _fileCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _fileCachingAndroidProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds."));
                    _fileCachingAndroidProp.intValue = Mathf.Clamp(_fileCachingAndroidProp.intValue, 0, 60000);

                    _liveCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _liveCachingAndroidProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds."));
                    _liveCachingAndroidProp.intValue = Mathf.Clamp(_liveCachingAndroidProp.intValue, 0, 60000);

                    _diskCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _diskCachingAndroidProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds."));
                    _diskCachingAndroidProp.intValue = Mathf.Clamp(_diskCachingAndroidProp.intValue, 0, 60000);

                    _networkCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _networkCachingAndroidProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds."));
                    _networkCachingAndroidProp.intValue = Mathf.Clamp(_networkCachingAndroidProp.intValue, 0, 60000);
                    #endregion
                }
                else
                {
                    var warningLabel = new GUIStyle(EditorStyles.textArea);
                    warningLabel.fontStyle = FontStyle.Bold;
                    EditorGUILayout.LabelField("Doesn't support any additional options for Android native player in this version.", warningLabel);
                }
            }
            #endregion
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            #region IPhone Options
            if (_availablePlatforms[_chosenPlatformProp.intValue] == IPHONE_CATEGORY_NAME)
            {
                if (!UMPPreference.Instance.UseIPhoneNative)
                {
                    #region VideoToolbox Options
                    _videoToolboxIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Hardware decoding: ", "This allows hardware decoding when available (enable VideoToolbox decoding)."), _videoToolboxIPhoneProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "This allows hardware decoding when available (enable VideoToolbox decoding)."));

                    if (_videoToolboxIPhoneProp.boolValue)
                    {
                        _videoToolboxMaxFrameWidthIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max width of output frame: ", "Max possible video resolution for hardware decoding."), _videoToolboxMaxFrameWidthIPhoneProp.intValue);
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max possible video resolution for hardware decoding."));
                        _videoToolboxMaxFrameWidthIPhoneProp.intValue = Mathf.Clamp(_videoToolboxMaxFrameWidthIPhoneProp.intValue, 0, 32768);

                        _videoToolboxAsyncIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Async decompression: ", "Use asynchronous decompression for hardware frame decoding."), _videoToolboxAsyncIPhoneProp.boolValue);
                        GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use asynchronous decompression for hardware frame decoding."));

                        if (_videoToolboxAsyncIPhoneProp.boolValue)
                        {
                            _videoToolboxWaitAsyncIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Wait for asynchronous frames: ", "Wait when frames is ready."), _videoToolboxWaitAsyncIPhoneProp.boolValue);
                            GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Wait when frames is ready."));
                        }
                    }
                    EditorGUILayout.Space();
                    #endregion

                    #region Background Options
                    _playInBackgroundIPhoneProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _playInBackgroundIPhoneProb.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
                    #endregion

                    #region RTP/RTSP/SDP Options
                    _rtspOverTcpIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpIPhoneProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
                    #endregion

                    #region Buffer Options
                    _packetBufferingIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Packet buffering: ", "Pause output until enough packets have been read after stalling."), _packetBufferingIPhoneProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Pause output until enough packets have been read after stalling."));

                    _maxBufferSizeIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max buffer size: ", "Max buffer size should be pre-read (in bytes)."), _maxBufferSizeIPhoneProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max buffer size should be pre-read."));
                    _maxBufferSizeIPhoneProp.intValue = Mathf.Clamp(_maxBufferSizeIPhoneProp.intValue, 0, 15 * 1024 * 1024);

                    _minFramesIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Min frames: ", "Minimal frames to stop pre-reading."), _minFramesIPhoneProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Minimal frames to stop pre-reading."));
                    _minFramesIPhoneProp.intValue = Mathf.Clamp(_minFramesIPhoneProp.intValue, 5, 50000);

                    _infbufIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Infbuf: ", "Don't limit the input buffer size (useful with realtime streams)."), _infbufIPhoneProp.boolValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Don't limit the input buffer size (useful with realtime streams)."));

                    EditorGUILayout.Space();
                    #endregion

                    #region Frame Options
                    _framedropIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Framedrop: ", "Drop frames when cpu is too slow."), _framedropIPhoneProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames when cpu is too slow."));
                    _framedropIPhoneProp.intValue = Mathf.Clamp(_framedropIPhoneProp.intValue, -1, 120);

                    _maxFpsIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max fps: ", "Drop frames in video whose fps is greater than max-fps."), _maxFpsIPhoneProp.intValue);
                    GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames in video whose fps is greater than max-fps."));
                    _maxFpsIPhoneProp.intValue = Mathf.Clamp(_maxFpsIPhoneProp.intValue, -1, 120);
                    #endregion
                }
                else
                {
                    var warningLabel = new GUIStyle(EditorStyles.textArea);
                    warningLabel.fontStyle = FontStyle.Bold;
                    EditorGUILayout.LabelField("Doesn't support any additional options for iOS native player in this version.", warningLabel);
                }
            }
            #endregion
            EditorGUI.EndDisabledGroup();

            EditorGUIUtility.labelWidth = _cachedLabelWidth;
        }
        else
        {
            _fileCachingDesktopProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _liveCachingDesktopProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _diskCachingDesktopProp.intValue    = PlayerOptions.DEFAULT_CACHING_VALUE;
            _networkCachingDesktopProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
            _fixedVideoWidthProp.intValue       = -1;
            _fixedVideoHeightProp.intValue      = -1;
        }

        if (UMPSettings.Instance.UseExternalLibs)
        {
            if (_externalPath.Equals(string.Empty))
            {
                _externalPath = UMPSettings.RuntimePlatformLibraryPath(true);
            }

            if (_externalPath != string.Empty)
            {
                var wrapTextStyle = EditorStyles.textArea;
                wrapTextStyle.wordWrap = true;
                EditorGUILayout.LabelField("Path to external/installed libraries: '" + _externalPath + "'", wrapTextStyle);
            }
        }
        else
        {
            _externalPath = string.Empty;
        }

        GUILayout.EndVertical();
        #endregion

        #region Player Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Player properties:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical("Box");

        GUILayout.BeginHorizontal();
        var centeredStyle = GUI.skin.GetStyle("Label");
        centeredStyle.alignment = TextAnchor.MiddleCenter;
        EditorGUILayout.LabelField("Volume", centeredStyle, GUILayout.MinWidth(80));
        if (GUILayout.Button("x", EditorStyles.miniButton))
        {
            _volumeProp.intValue = 50;
        }
        GUILayout.EndHorizontal();

        _volumeProp.intValue = EditorGUILayout.IntSlider(_volumeProp.intValue, 0, 100);
        GUILayout.EndVertical();

        GUILayout.BeginVertical("Box");

        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Play rate", centeredStyle, GUILayout.MinWidth(80));
        if (GUILayout.Button("x", EditorStyles.miniButton))
        {
            _playRateProp.floatValue = 1f;
        }
        GUILayout.EndHorizontal();

        _playRateProp.floatValue = EditorGUILayout.Slider(_playRateProp.floatValue, 0.5f, 5f);
        GUILayout.EndVertical();

        GUILayout.EndHorizontal();

        EditorGUI.BeginDisabledGroup(!umpEditor.IsReady);
        EditorGUILayout.Space();
        GUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Position", centeredStyle, GUILayout.MinWidth(100));
        _positionProp.floatValue = EditorGUILayout.Slider(_positionProp.floatValue, 0f, 1f);
        GUILayout.EndVertical();
        EditorGUI.EndDisabledGroup();

        EditorGUI.BeginDisabledGroup(!Application.isPlaying || !umpEditor.isActiveAndEnabled || umpEditor.IsParsing);
        GUILayout.BeginHorizontal("Box");
        if (GUILayout.Button("LOAD", GUILayout.MinWidth(40)))
        {
            umpEditor.Prepare();
        }
        if (GUILayout.Button("PLAY", GUILayout.MinWidth(40)))
        {
            umpEditor.Play();
        }
        if (GUILayout.Button("PAUSE", GUILayout.MinWidth(40)))
        {
            umpEditor.Pause();
        }
        if (GUILayout.Button("STOP", GUILayout.MinWidth(40)))
        {
            umpEditor.Stop();
        }
        if (GUILayout.Button("SHOT", GUILayout.MinWidth(40)))
        {
            umpEditor.Snapshot(Application.persistentDataPath);
        }
        GUILayout.EndHorizontal();
        EditorGUI.EndDisabledGroup();
        #endregion

        #region Events & Logging Fields
        EditorGUILayout.Space();
        EditorStyles.label.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("Events & Logging:");
        EditorStyles.label.fontStyle = _cachedFontStyle;

        GUILayout.BeginVertical("Box");
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        EditorGUILayout.PropertyField(_logDetailProp, GUILayout.MinWidth(50));
        EditorGUI.EndDisabledGroup();

        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Last msg: ", GUILayout.MinWidth(70));
        EditorStyles.label.normal.textColor = Color.black;
        EditorStyles.label.fontStyle        = FontStyle.Italic;
        EditorStyles.label.wordWrap         = true;
        EditorGUILayout.LabelField(_lastEventMsgProp.stringValue, GUILayout.MaxWidth(100));
        EditorStyles.label.normal.textColor = _cachedTextColor;
        EditorStyles.label.fontStyle        = _cachedFontStyle;
        EditorStyles.label.wordWrap         = _cachedLabelWordWrap;
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        _showEventsListeners = EditorGUILayout.Foldout(_showEventsListeners, "Event Listeners");

        if (_showEventsListeners)
        {
            EditorGUILayout.PropertyField(_pathPreparedEventProp, new GUIContent("Path Prepared"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_openingEventProp, new GUIContent("Opening"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_bufferingEventProp, new GUIContent("Buffering"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_preparedEventProp, new GUIContent("Prepared"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_playingEventProp, new GUIContent("Playing"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_pausedEventProp, new GUIContent("Paused"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_stoppedEventProp, new GUIContent("Stopped"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_endReachedEventProp, new GUIContent("End Reached"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_encounteredErrorEventProp, new GUIContent("Encountered Error"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_timeChangedEventProp, new GUIContent("Time Changed"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_positionChangedEventProp, new GUIContent("Position Changed"), true, GUILayout.MinWidth(50));
            EditorGUILayout.PropertyField(_snapshotTakenEventProp, new GUIContent("Snapshot"), true, GUILayout.MinWidth(50));
        }
        #endregion

        EditorStyles.label.normal.textColor = _cachedTextColor;
        EditorStyles.label.fontStyle        = _cachedFontStyle;

        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }