Example #1
0
 public void ShowConfigWindow()
 {
     if (_hasConfigWindow)
     {
         if (_codecType == CodecType.Video)
         {
             NativePlugin.ConfigureVideoCodec(_index);
         }
         else if (_codecType == CodecType.Audio)
         {
             NativePlugin.ConfigureAudioCodec(_index);
         }
     }
 }
Example #2
0
        private void MyWindow(int id)
        {
            if (_movieCapture == null)
            {
                GUILayout.Label("CaptureGUI - No CaptureFrom component set");
                return;
            }

            if (_movieCapture.IsCapturing())
            {
                GUI_RecordingStatus();
                return;
            }

            GUILayout.BeginVertical();

            if (_movieCapture != null)
            {
                GUILayout.Label("Resolution:");
                GUILayout.BeginHorizontal();
                _downScaleIndex = GUILayout.SelectionGrid(_downScaleIndex, _downScales, _downScales.Length);
                switch (_downScaleIndex)
                {
                case 0:
                    _movieCapture._downScale = CaptureBase.DownScale.Original;
                    break;

                case 1:
                    _movieCapture._downScale = CaptureBase.DownScale.Half;
                    break;

                case 2:
                    _movieCapture._downScale = CaptureBase.DownScale.Quarter;
                    break;

                case 3:
                    _movieCapture._downScale = CaptureBase.DownScale.Eighth;
                    break;

                case 4:
                    _movieCapture._downScale = CaptureBase.DownScale.Sixteenth;
                    break;

                case 5:
                    _movieCapture._downScale = CaptureBase.DownScale.Custom;
                    break;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(GUILayout.Width(256));
                if (_movieCapture._downScale == CaptureBase.DownScale.Custom)
                {
                    string maxWidthString = GUILayout.TextField(Mathf.FloorToInt(_movieCapture._maxVideoSize.x).ToString(), 4);
                    int    maxWidth       = 0;
                    if (int.TryParse(maxWidthString, out maxWidth))
                    {
                        _movieCapture._maxVideoSize.x = Mathf.Clamp(maxWidth, 0, 16384);
                    }

                    GUILayout.Label("x", GUILayout.Width(20));

                    string maxHeightString = GUILayout.TextField(Mathf.FloorToInt(_movieCapture._maxVideoSize.y).ToString(), 4);
                    int    maxHeight       = 0;
                    if (int.TryParse(maxHeightString, out maxHeight))
                    {
                        _movieCapture._maxVideoSize.y = Mathf.Clamp(maxHeight, 0, 16384);
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Frame Rate:");
                _frameRateIndex = GUILayout.SelectionGrid(_frameRateIndex, _frameRates, _frameRates.Length);
                switch (_frameRateIndex)
                {
                case 0:
                    _movieCapture._frameRate = CaptureBase.FrameRate.One;
                    break;

                case 1:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Ten;
                    break;

                case 2:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Fifteen;
                    break;

                case 3:
                    _movieCapture._frameRate = CaptureBase.FrameRate.TwentyFour;
                    break;

                case 4:
                    _movieCapture._frameRate = CaptureBase.FrameRate.TwentyFive;
                    break;

                case 5:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Thirty;
                    break;

                case 6:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Fifty;
                    break;

                case 7:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Sixty;
                    break;

                case 8:
                    _movieCapture._frameRate = CaptureBase.FrameRate.SeventyFive;
                    break;

                case 9:
                    _movieCapture._frameRate = CaptureBase.FrameRate.Ninety;
                    break;

                case 10:
                    _movieCapture._frameRate = CaptureBase.FrameRate.OneTwenty;
                    break;
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(16f);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Output:", GUILayout.ExpandWidth(false));
                _movieCapture._outputType = (CaptureBase.OutputType)GUILayout.SelectionGrid((int)_movieCapture._outputType, _outputType, _outputType.Length);
                GUILayout.EndHorizontal();

                GUILayout.Space(16f);

                _movieCapture._isRealTime = GUILayout.Toggle(_movieCapture._isRealTime, "RealTime");

                GUILayout.Space(16f);


                if (_movieCapture._outputType == CaptureBase.OutputType.VideoFile)
                {
                    // Video Codec
                    GUILayout.BeginHorizontal();
                    if (_shownSection != 0)
                    {
                        if (GUILayout.Button("+", GUILayout.Width(24)))
                        {
                            _shownSection = 0;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("-", GUILayout.Width(24)))
                        {
                            _shownSection = -1;
                        }
                    }
                    GUILayout.Label("Using Video Codec: " + _movieCapture._codecName);
                    if (_movieCapture._codecIndex >= 0 && _videoCodecConfigurable[_movieCapture._codecIndex])
                    {
                        GUILayout.Space(16f);
                        if (GUILayout.Button("Configure Codec"))
                        {
                            NativePlugin.ConfigureVideoCodec(_movieCapture._codecIndex);
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (_videoCodecNames != null && _shownSection == 0)
                    {
                        GUILayout.Label("Select Video Codec:");
                        _videoPos = GUILayout.BeginScrollView(_videoPos, GUILayout.Height(100));
                        int newCodecIndex = GUILayout.SelectionGrid(-1, _videoCodecNames, 1) - 2;
                        GUILayout.EndScrollView();

                        if (newCodecIndex >= -2)
                        {
                            _movieCapture._codecIndex = newCodecIndex;
                            if (_movieCapture._codecIndex >= 0)
                            {
                                _movieCapture._codecName = _videoCodecNames[_movieCapture._codecIndex + 2];
                                _movieCapture._useMediaFoundationH264 = false;
                            }
                            else
                            {
                                if (_movieCapture._codecIndex == -2)
                                {
                                    _movieCapture._codecName = "Uncompressed";
                                    _movieCapture._useMediaFoundationH264 = false;
                                }
                                else
                                {
                                    if (_movieCapture._codecIndex == -1)
                                    {
                                        _movieCapture._codecName = "Media Foundation H.264(MP4)";
                                        _movieCapture._useMediaFoundationH264 = true;
                                    }
                                }
                            }

                            _shownSection = -1;
                        }

                        GUILayout.Space(16f);
                    }


                    GUI.enabled            = _movieCapture._isRealTime;
                    _movieCapture._noAudio = !GUILayout.Toggle(!_movieCapture._noAudio, "Record Audio");
                    if (GUI.enabled)
                    {
                        GUI.enabled = !_movieCapture._noAudio;
                    }

                    // Audio Device
                    GUILayout.BeginHorizontal();
                    if (_shownSection != 1)
                    {
                        if (GUILayout.Button("+", GUILayout.Width(24)))
                        {
                            _shownSection = 1;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("-", GUILayout.Width(24)))
                        {
                            _shownSection = -1;
                        }
                    }
                    GUILayout.Label("Using Audio Source: " + _movieCapture._audioDeviceName);
                    GUILayout.EndHorizontal();
                    if (_audioDeviceNames != null && _shownSection == 1)
                    {
                        GUILayout.Label("Select Audio Source:");
                        _audioPos = GUILayout.BeginScrollView(_audioPos, GUILayout.Height(100));
                        int newAudioIndex = GUILayout.SelectionGrid(-1, _audioDeviceNames, 1) - 1;
                        GUILayout.EndScrollView();

                        if (newAudioIndex >= -1)
                        {
                            _movieCapture._audioDeviceIndex = newAudioIndex;
                            if (_movieCapture._audioDeviceIndex >= 0)
                            {
                                _movieCapture._audioDeviceName = _audioDeviceNames[_movieCapture._audioDeviceIndex + 1];
                            }
                            else
                            {
                                _movieCapture._audioDeviceName = "Unity";
                            }

                            _shownSection = -1;
                        }

                        GUILayout.Space(16f);
                    }



                    // Audio Codec
                    GUILayout.BeginHorizontal();
                    if (_shownSection != 2)
                    {
                        if (GUILayout.Button("+", GUILayout.Width(24)))
                        {
                            _shownSection = 2;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("-", GUILayout.Width(24)))
                        {
                            _shownSection = -1;
                        }
                    }
                    GUILayout.Label("Using Audio Codec: " + _movieCapture._audioCodecName);
                    if (_movieCapture._audioCodecIndex >= 0 && _audioCodecConfigurable[_movieCapture._audioCodecIndex])
                    {
                        GUILayout.Space(16f);
                        if (GUILayout.Button("Configure Codec"))
                        {
                            NativePlugin.ConfigureAudioCodec(_movieCapture._audioCodecIndex);
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (_audioCodecNames != null && _shownSection == 2)
                    {
                        GUILayout.Label("Select Audio Codec:");
                        _audioCodecPos = GUILayout.BeginScrollView(_audioCodecPos, GUILayout.Height(100));
                        int newCodecIndex = GUILayout.SelectionGrid(-1, _audioCodecNames, 1) - 1;
                        GUILayout.EndScrollView();

                        if (newCodecIndex >= -1)
                        {
                            _movieCapture._audioCodecIndex = newCodecIndex;
                            if (_movieCapture._audioCodecIndex >= 0)
                            {
                                _movieCapture._audioCodecName = _audioCodecNames[_movieCapture._audioCodecIndex + 1];
                            }
                            else
                            {
                                _movieCapture._audioCodecName = "Uncompressed";
                            }

                            _shownSection = -1;
                        }

                        GUILayout.Space(16f);
                    }

                    GUI.enabled = true;

                    GUILayout.Space(16f);
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Filename Prefix & Ext: ");
                _movieCapture._autoFilenamePrefix = GUILayout.TextField(_movieCapture._autoFilenamePrefix, 64);
                if (_movieCapture._outputType == CaptureBase.OutputType.VideoFile)
                {
                    _movieCapture._autoFilenameExtension = GUILayout.TextField(_movieCapture._autoFilenameExtension, 8);
                }
                else if (_movieCapture._outputType == CaptureBase.OutputType.ImageSequence)
                {
                    GUILayout.TextField("png", 8);
                }
                else if (_movieCapture._outputType == CaptureBase.OutputType.NamedPipe)
                {
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(16f);
                GUILayout.Space(16f);

                if (_whenRecordingAutoHideUI)
                {
                    GUILayout.Label("(Press CTRL-F5 to stop capture)");
                }

                GUILayout.BeginHorizontal();
                if (!_movieCapture.IsCapturing())
                {
                    GUI.color = Color.green;
                    if (GUILayout.Button(_movieCapture._isRealTime?"Start Capture":"Start Render"))
                    {
                        StartCapture();
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    /*if (!_movieCapture.IsPaused())
                     * {
                     *      if (GUILayout.Button("Pause Capture"))
                     *      {
                     *              PauseCapture();
                     *      }
                     * }
                     * else
                     * {
                     *      if (GUILayout.Button("Resume Capture"))
                     *      {
                     *              ResumeCapture();
                     *      }
                     * }
                     *
                     * if (GUILayout.Button("Cancel Capture"))
                     * {
                     *      CancelCapture();
                     * }
                     * if (GUILayout.Button("Stop Capture"))
                     * {
                     *      StopCapture();
                     * }*/
                }
                GUILayout.EndHorizontal();

                if (_movieCapture.IsCapturing())
                {
                    if (!string.IsNullOrEmpty(_movieCapture.LastFilePath))
                    {
                        GUILayout.Label("Writing file: '" + System.IO.Path.GetFileName(_movieCapture.LastFilePath) + "'");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(CaptureBase.LastFileSaved))
                    {
                        GUILayout.Space(16f);
                        GUILayout.Label("Last file written: '" + System.IO.Path.GetFileName(CaptureBase.LastFileSaved) + "'");

                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("Browse"))
                        {
                            Utils.ShowInExplorer(CaptureBase.LastFileSaved);
                        }
                        Color prevColor = GUI.color;
                        GUI.color = Color.cyan;
                        if (GUILayout.Button("View Last Capture"))
                        {
                            Utils.OpenInDefaultApp(CaptureBase.LastFileSaved);
                        }
                        GUI.color = prevColor;

                        GUILayout.EndHorizontal();
                    }
                }
            }

            GUILayout.EndVertical();
        }