コード例 #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Capture Cameras
            GUILayout.Label("Capture Cameras", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(regularCamera, new GUIContent("Regular Camera"), true);
            EditorGUILayout.PropertyField(stereoCamera, new GUIContent("Stereo Camera"), true);

            // Capture Control Section
            GUILayout.Label("Capture Controls", EditorStyles.boldLabel);

            videoCapture.startOnAwake = EditorGUILayout.Toggle("Start On Awake", videoCapture.startOnAwake);
            if (videoCapture.startOnAwake)
            {
                videoCapture.captureTime      = EditorGUILayout.FloatField("Capture Duration (Sec)", videoCapture.captureTime);
                videoCapture.quitAfterCapture = EditorGUILayout.Toggle("Quit After Capture", videoCapture.quitAfterCapture);
            }

            // Capture Options Section
            GUILayout.Label("Capture Options", EditorStyles.boldLabel);

            videoCapture.captureSource = (CaptureSource)EditorGUILayout.EnumPopup("Capture Source", videoCapture.captureSource);

            if (videoCapture.captureSource == CaptureSource.RENDERTEXTURE)
            {
                EditorGUILayout.PropertyField(inputTexture, new GUIContent("Render Texture"), true);
            }

            videoCapture.captureType = (CaptureType)EditorGUILayout.EnumPopup("Capture Type", videoCapture.captureType);
            if (videoCapture.captureType == CaptureType.VOD)
            {
                videoCapture.saveFolder = EditorGUILayout.TextField("Save Folder", videoCapture.saveFolder);
            }
            else if (videoCapture.captureType == CaptureType.LIVE)
            {
                videoCapture.liveStreamUrl = EditorGUILayout.TextField("Live Stream Url", videoCapture.liveStreamUrl);
            }
            if (videoCapture.captureSource == CaptureSource.CAMERA)
            {
                videoCapture.captureMode = (CaptureMode)EditorGUILayout.EnumPopup("Capture Mode", videoCapture.captureMode);

                if (videoCapture.captureMode == CaptureMode._360)
                {
                    videoCapture.projectionType = (ProjectionType)EditorGUILayout.EnumPopup("Projection Type", videoCapture.projectionType);
                }

                if (videoCapture.captureMode == CaptureMode._360 &&
                    videoCapture.projectionType == ProjectionType.CUBEMAP)
                {
                    videoCapture.stereoMode = StereoMode.NONE;
                }
                else
                {
                    videoCapture.stereoMode = (StereoMode)EditorGUILayout.EnumPopup("Stereo Mode", videoCapture.stereoMode);
                }
                if (videoCapture.stereoMode != StereoMode.NONE)
                {
                    videoCapture.interpupillaryDistance = EditorGUILayout.FloatField("Interpupillary Distance", videoCapture.interpupillaryDistance);
                }
            }
            else
            {
                videoCapture.captureMode    = CaptureMode.REGULAR;
                videoCapture.projectionType = ProjectionType.NONE;
                videoCapture.stereoMode     = StereoMode.NONE;
            }

            if (videoCapture.captureSource == CaptureSource.SCREEN)
            {
                videoCapture.captureCursor = EditorGUILayout.Toggle("Capture Cursor", videoCapture.captureCursor);
                if (videoCapture.captureCursor)
                {
                    EditorGUILayout.PropertyField(cursorImage, new GUIContent("Cursor Image"), true);
                }
            }

            videoCapture.captureAudio = EditorGUILayout.Toggle("Capture Audio", videoCapture.captureAudio);
            if (videoCapture.captureAudio)
            {
                videoCapture.captureMicrophone = EditorGUILayout.Toggle("Capture Microphone", videoCapture.captureMicrophone);
                if (videoCapture.captureMicrophone)
                {
                    videoCapture.deviceIndex = EditorGUILayout.IntField("Device Index", videoCapture.deviceIndex);
                }
            }
            videoCapture.offlineRender = EditorGUILayout.Toggle("Offline Render", videoCapture.offlineRender);
            videoCapture.screenBlitter = EditorGUILayout.Toggle("Screen Blitter", videoCapture.screenBlitter);

            // Capture Options Section
            GUILayout.Label("Video Settings", EditorStyles.boldLabel);

            if (videoCapture.captureSource == CaptureSource.CAMERA)
            {
                videoCapture.resolutionPreset = (ResolutionPreset)EditorGUILayout.EnumPopup("Resolution Preset", videoCapture.resolutionPreset);
                if (videoCapture.resolutionPreset == ResolutionPreset.CUSTOM)
                {
                    videoCapture.frameWidth  = EditorGUILayout.IntField("Frame Width", videoCapture.frameWidth);
                    videoCapture.frameHeight = EditorGUILayout.IntField("Frame Height", videoCapture.frameHeight);
                    videoCapture.bitrate     = EditorGUILayout.IntField("Bitrate (Kbps)", videoCapture.bitrate);
                }
            }
            else
            {
                videoCapture.bitrate = EditorGUILayout.IntField("Bitrate (Kbps)", videoCapture.bitrate);
            }

            videoCapture.frameRate      = (System.Int16)EditorGUILayout.IntField("Frame Rate", videoCapture.frameRate);
            videoCapture.verticalFlip   = EditorGUILayout.Toggle("Vertical Flip", videoCapture.verticalFlip);
            videoCapture.horizontalFlip = EditorGUILayout.Toggle("Horizontal Flip", videoCapture.horizontalFlip);
            if (videoCapture.captureMode == CaptureMode._360)
            {
                videoCapture.cubemapFaceSize = (CubemapFaceSize)EditorGUILayout.EnumPopup("Cubemap Face Size", videoCapture.cubemapFaceSize);
            }
            videoCapture.antiAliasing = (AntiAliasingSetting)EditorGUILayout.EnumPopup("Anti Aliasing", videoCapture.antiAliasing);

            if (videoCapture.captureSource == CaptureSource.CAMERA)
            {
                videoCapture.transparent = EditorGUILayout.Toggle("Transparent", videoCapture.transparent);
            }

            // Capture Options Section
            GUILayout.Label("Encoder Settings", EditorStyles.boldLabel);

            videoCapture.encoderPreset = (EncoderPreset)EditorGUILayout.EnumPopup("Encoder Preset", videoCapture.encoderPreset);
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (!FreeTrial.Check())
            {
                videoCapture.gpuEncoding = EditorGUILayout.Toggle("GPU Encoding", videoCapture.gpuEncoding);
            }
            if (videoCapture.gpuEncoding)
            {
                videoCapture.legacyGpuEncoding = EditorGUILayout.Toggle("Legacy GPU Encoding", videoCapture.legacyGpuEncoding);
            }
#endif

            // Internal Settings
            GUILayout.Label("Internal Settings", EditorStyles.boldLabel);
            videoCapture.enableInternalSettings = EditorGUILayout.Toggle("Enable", videoCapture.enableInternalSettings);

            if (videoCapture.enableInternalSettings)
            {
                // Capture Encoder
                GUILayout.Label("Capture Encoders", EditorStyles.boldLabel);

                EditorGUILayout.PropertyField(ffmpegEncoder, new GUIContent("FFmpeg Encoder"), true);
                EditorGUILayout.PropertyField(nvidiaEncoder, new GUIContent("Nvidia Encoder"), true);
                EditorGUILayout.PropertyField(gpuEncoder, new GUIContent("GPU Encoder"), true);
            }

            //// Tools Section
            //GUILayout.Label("Tools", EditorStyles.boldLabel);
            GUILayout.Space(10);

            if (GUILayout.Button("Browse"))
            {
                // Open video save directory
                Utils.BrowseFolder(videoCapture.saveFolder);
            }
            //if (GUILayout.Button("Convert Last Video to WMV"))
            //{
            //  Utils.ConvertVideoWmv(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Convert Last Video to AVI"))
            //{
            //  Utils.ConvertVideoAvi(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Convert Last Video to FLV"))
            //{
            //  Utils.ConvertVideoFlv(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Convert Last Video to MKV"))
            //{
            //  Utils.ConvertVideoMkv(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Convert Last Video to GIF"))
            //{
            //  Utils.ConvertVideoGif(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Encode Last Video to 4K"))
            //{
            //  Utils.EncodeVideo4K(VideoSaveUtils.lastVideoFile);
            //}
            //if (GUILayout.Button("Encode Last Video to 8K"))
            //{
            //  Utils.EncodeVideo8K(VideoSaveUtils.lastVideoFile);
            //}

            GUILayout.Space(10);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }

            // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        /// <summary>
        /// Private properties.
        /// </summary>
        // The garbage collection thread.
        //private Thread garbageCollectionThread;
        //private static bool garbageThreadRunning = false;

        #endregion

        #region Video Capture

        /// <summary>
        /// Initialize the attributes of the capture session and start capture.
        /// </summary>
        public override bool StartCapture()
        {
            if (!PrepareCapture())
            {
                return(false);
            }

            if (offlineRender)
            {
                Time.captureFramerate = frameRate;
            }

            // init ffmpeg encoding settings
            FFmpegEncoderSettings();

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (gpuEncoding)
            {
                if (FreeTrial.Check())
                {
                    Debug.LogFormat(LOG_FORMAT, "GPU encoding is not supported in free trial version, fall back to software encoding.");
                    gpuEncoding = false;
                }

                if (SystemInfo.graphicsDeviceVendor == "NVIDIA")
                {
                    // init nvidia encoding settings
                    NvidiaEncoderSettings();
                    nvidiaEncoding = true;
                    if (legacyGpuEncoding)
                    {
                        GPUEncoderSettings();
                        nvidiaEncoding = false;
                    }
                }
                else
                {
                    // init GPU encoding settings
                    GPUEncoderSettings();
                    nvidiaEncoding = false;
                }

                if (gpuEncoding && !nvidiaEncoding)
                {
                    if (!gpuEncoder.instantiated || !gpuEncoder.IsSupported())
                    {
                        Debug.LogFormat(LOG_FORMAT, "GPU encoding is not supported in current device or settings, fall back to software encoding.");
                        gpuEncoding = false;
                    }
                }
            }
#else
            if (gpuEncoding)
            {
                Debug.LogFormat(LOG_FORMAT, "GPU encoding is only available on windows system, fall back to software encoding.");
                gpuEncoding = false;
            }
#endif

            // Init audio recorder
            if ((!gpuEncoding && captureAudio) || (nvidiaEncoding && captureAudio))
            {
                if (captureMicrophone)
                {
                    if (MicrophoneRecorder.singleton == null)
                    {
                        gameObject.AddComponent <MicrophoneRecorder>();
                    }
                    MicrophoneRecorder.singleton.saveFolderFullPath = saveFolderFullPath;
                    MicrophoneRecorder.singleton.captureType        = captureType;
                    MicrophoneRecorder.singleton.deviceIndex        = deviceIndex;
                    microphoneRecorder = MicrophoneRecorder.singleton;
                }

                if (AudioRecorder.singleton == null)
                {
                    if (GetComponent <DontDestroy>() != null)
                    {
                        // Reset AudioListener
                        AudioListener listener = FindObjectOfType <AudioListener>();
                        if (listener)
                        {
                            Destroy(listener);
                            Debug.LogFormat(LOG_FORMAT, "AudioListener found, reset in game scene.");
                        }
                        gameObject.AddComponent <AudioListener>();
                        gameObject.AddComponent <AudioRecorder>();
                    }
                    else
                    {
                        // Keep AudioListener
                        AudioListener listener = FindObjectOfType <AudioListener>();
                        if (!listener)
                        {
                            listener = gameObject.AddComponent <AudioListener>();
                            Debug.LogFormat(LOG_FORMAT, "AudioListener not found, add a new AudioListener.");
                        }
                        listener.gameObject.AddComponent <AudioRecorder>();
                    }
                }
                AudioRecorder.singleton.saveFolderFullPath = saveFolderFullPath;
                AudioRecorder.singleton.captureType        = captureType;
                audioRecorder = AudioRecorder.singleton;
            }

            // Init ffmpeg muxer
            if ((!gpuEncoding && captureAudio) || (nvidiaEncoding && captureAudio))
            {
                if (FFmpegMuxer.singleton == null)
                {
                    gameObject.AddComponent <FFmpegMuxer>();
                }
                FFmpegMuxer.singleton.ffmpegFullPath     = ffmpegFullPath;
                FFmpegMuxer.singleton.customFileName     = customFileName;
                FFmpegMuxer.singleton.saveFolderFullPath = saveFolderFullPath;
                FFmpegMuxer.singleton.AttachVideoCapture(this);
                FFmpegMuxer.singleton.verticalFlip = verticalFlip;
                if (nvidiaEncoding)
                {
                    if (captureSource != CaptureSource.SCREEN)
                    {
                        FFmpegMuxer.singleton.verticalFlip = !verticalFlip;
                    }
                }
                FFmpegMuxer.singleton.horizontalFlip = horizontalFlip;
            }

            // Init ffmpeg transcoder
            if (gpuEncoding && nvidiaEncoding && !captureAudio)
            {
                if (FFmpegTranscoder.singleton == null)
                {
                    gameObject.AddComponent <FFmpegTranscoder>();
                }
                FFmpegTranscoder.singleton.ffmpegFullPath     = ffmpegFullPath;
                FFmpegTranscoder.singleton.customFileName     = customFileName;
                FFmpegTranscoder.singleton.saveFolderFullPath = saveFolderFullPath;
                FFmpegTranscoder.singleton.AttachVideoCapture(this);
                FFmpegTranscoder.singleton.verticalFlip = verticalFlip;
                if (captureSource != CaptureSource.SCREEN)
                {
                    FFmpegTranscoder.singleton.verticalFlip = !verticalFlip;
                }
                FFmpegTranscoder.singleton.horizontalFlip = horizontalFlip;
            }

            // Init ffmpeg streamer
            if (!gpuEncoding && captureType == CaptureType.LIVE)
            {
                if (FFmpegStreamer.singleton == null)
                {
                    gameObject.AddComponent <FFmpegStreamer>();
                }
                FFmpegStreamer.singleton.ffmpegFullPath = ffmpegFullPath;
                FFmpegStreamer.singleton.captureAudio   = captureAudio;
                FFmpegStreamer.singleton.liveStreamUrl  = liveStreamUrl;
                FFmpegStreamer.singleton.bitrate        = bitrate;
            }

            if (gpuEncoding)
            {
                if (nvidiaEncoding)
                {
                    if (!nvidiaEncoder.StartCapture())
                    {
                        OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.VIDEO_CAPTURE_START_FAILED));
                        return(false);
                    }

                    if (captureAudio)
                    {
                        if (!audioRecorder.RecordStarted())
                        {
                            audioRecorder.StartRecord();
                        }

                        if (captureMicrophone)
                        {
                            if (!microphoneRecorder.RecordStarted())
                            {
                                microphoneRecorder.StartRecord();
                            }
                        }
                    }
                }
                else
                {
                    if (!gpuEncoder.StartCapture())
                    {
                        OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.VIDEO_CAPTURE_START_FAILED));
                        return(false);
                    }
                }
            }
            else
            {
                if (!ffmpegEncoder.StartCapture())
                {
                    OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.VIDEO_CAPTURE_START_FAILED));
                    return(false);
                }

                if (captureAudio)
                {
                    if (!audioRecorder.RecordStarted())
                    {
                        audioRecorder.StartRecord();
                    }
                    if (captureMicrophone)
                    {
                        if (!microphoneRecorder.RecordStarted())
                        {
                            microphoneRecorder.StartRecord();
                        }
                    }
                }

                if (captureType == CaptureType.LIVE)
                {
                    // start ffmpeg live streamer
                    if (!FFmpegStreamer.singleton.streamStarted)
                    {
                        FFmpegStreamer.singleton.StartStream();
                    }
                }
            }

            // Create a blitter object to keep frames presented on the screen
            if (screenBlitter)
            {
                CreateBlitterInstance();
            }

            // Update current status.
            status = CaptureStatus.STARTED;

            // Start garbage collect thread.
            //if (!garbageThreadRunning)
            //{
            //  garbageThreadRunning = true;

            //  if (garbageCollectionThread != null &&
            //    garbageCollectionThread.IsAlive)
            //  {
            //    garbageCollectionThread.Abort();
            //    garbageCollectionThread = null;
            //  }

            //  garbageCollectionThread = new Thread(GarbageCollectionProcess);
            //  garbageCollectionThread.Priority = System.Threading.ThreadPriority.Lowest;
            //  garbageCollectionThread.IsBackground = true;
            //  garbageCollectionThread.Start();
            //}

            Debug.LogFormat(LOG_FORMAT, "Video capture session started.");
            return(true);
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            // Capture Cameras
            GUILayout.Label("Capture Cameras", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(regularCamera, new GUIContent("Regular Camera"), true);
            EditorGUILayout.PropertyField(stereoCamera, new GUIContent("Stereo Camera"), true);

            // Capture Options Section
            GUILayout.Label("Capture Options", EditorStyles.boldLabel);

            screenshot.saveFolder = EditorGUILayout.TextField("Save Folder", screenshot.saveFolder);

            screenshot.captureMode = (CaptureMode)EditorGUILayout.EnumPopup("Capture Mode", screenshot.captureMode);
            if (screenshot.captureMode == CaptureMode._360)
            {
                screenshot.projectionType = (ProjectionType)EditorGUILayout.EnumPopup("Projection Type", screenshot.projectionType);
            }
            if (screenshot.captureMode == CaptureMode._360 &&
                screenshot.projectionType == ProjectionType.CUBEMAP)
            {
                screenshot.stereoMode = StereoMode.NONE;
            }
            else
            {
                screenshot.stereoMode = (StereoMode)EditorGUILayout.EnumPopup("Stereo Mode", screenshot.stereoMode);
            }
            if (screenshot.stereoMode != StereoMode.NONE)
            {
                screenshot.interpupillaryDistance = EditorGUILayout.FloatField("Interpupillary Distance", screenshot.interpupillaryDistance);
            }

            // Capture Options Section
            GUILayout.Label("Screenshot Settings", EditorStyles.boldLabel);

            screenshot.resolutionPreset = (ResolutionPreset)EditorGUILayout.EnumPopup("Resolution Preset", screenshot.resolutionPreset);
            if (screenshot.resolutionPreset == ResolutionPreset.CUSTOM)
            {
                screenshot.frameWidth  = EditorGUILayout.IntField("Frame Width", screenshot.frameWidth);
                screenshot.frameHeight = EditorGUILayout.IntField("Frame Height", screenshot.frameHeight);
            }
            if (screenshot.captureMode == CaptureMode._360)
            {
                screenshot.cubemapFaceSize = (CubemapFaceSize)EditorGUILayout.EnumPopup("Cubemap Face Size", screenshot.cubemapFaceSize);
            }
            screenshot.antiAliasingSetting = (AntiAliasingSetting)EditorGUILayout.EnumPopup("Anti Aliasing Settings", screenshot.antiAliasingSetting);

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            // Capture Options Section
            GUILayout.Label("Encoder Settings", EditorStyles.boldLabel);
            if (!FreeTrial.Check())
            {
                screenshot.gpuEncoding = EditorGUILayout.Toggle("GPU Encoding", screenshot.gpuEncoding);
            }
#endif

            //// Tools Section
            //GUILayout.Label("Tools", EditorStyles.boldLabel);
            GUILayout.Space(10);

            if (GUILayout.Button("Browse"))
            {
                // Open video save directory
                Utils.BrowseFolder(screenshot.saveFolder);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }

            // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            // Capture Control Section
            GUILayout.Label("Capture Control", EditorStyles.boldLabel);

            manager.startOnAwake = EditorGUILayout.Toggle("Start On Awake", manager.startOnAwake);

            if (manager.startOnAwake)
            {
                manager.captureTime      = EditorGUILayout.FloatField("Capture Duration (Sec)", manager.captureTime);
                manager.quitAfterCapture = EditorGUILayout.Toggle("Quit After Capture", manager.quitAfterCapture);
            }

            // Capture Options Section
            GUILayout.Label("Capture Options", EditorStyles.boldLabel);

            manager.saveFolder  = EditorGUILayout.TextField("Save Folder", manager.saveFolder);
            manager.captureMode = (CaptureMode)EditorGUILayout.EnumPopup("Capture Mode", manager.captureMode);
            if (manager.captureMode == CaptureMode._360)
            {
                manager.projectionType = (ProjectionType)EditorGUILayout.EnumPopup("Projection Type", manager.projectionType);
            }
            if (manager.captureMode == CaptureMode._360 &&
                manager.projectionType == ProjectionType.CUBEMAP)
            {
                manager.stereoMode = StereoMode.NONE;
            }
            else
            {
                manager.stereoMode = (StereoMode)EditorGUILayout.EnumPopup("Stereo Mode", manager.stereoMode);
            }
            if (manager.stereoMode != StereoMode.NONE)
            {
                manager.interpupillaryDistance = EditorGUILayout.FloatField("Interpupillary Distance", manager.interpupillaryDistance);
            }
            manager.captureAudio = EditorGUILayout.Toggle("Capture Audio", manager.captureAudio);
            if (manager.captureAudio)
            {
                manager.captureMicrophone = EditorGUILayout.Toggle("Capture Microphone", manager.captureMicrophone);
                if (manager.captureMicrophone)
                {
                    manager.deviceIndex = EditorGUILayout.IntField("Device Index", manager.deviceIndex);
                }
            }
            manager.offlineRender = EditorGUILayout.Toggle("Offline Render", manager.offlineRender);

            // Capture Options Section
            GUILayout.Label("Video Settings", EditorStyles.boldLabel);

            manager.resolutionPreset = (ResolutionPreset)EditorGUILayout.EnumPopup("Resolution Preset", manager.resolutionPreset);
            if (manager.resolutionPreset == ResolutionPreset.CUSTOM)
            {
                manager.frameWidth  = EditorGUILayout.IntField("Frame Width", manager.frameWidth);
                manager.frameHeight = EditorGUILayout.IntField("Frame Height", manager.frameHeight);
                manager.bitrate     = EditorGUILayout.IntField("Bitrate (Kbps)", manager.bitrate);
            }
            manager.frameRate = (System.Int16)EditorGUILayout.IntField("Frame Rate", manager.frameRate);
            if (manager.captureMode == CaptureMode._360)
            {
                manager.cubemapFaceSize = (CubemapFaceSize)EditorGUILayout.EnumPopup("Cubemap Face Size", manager.cubemapFaceSize);
            }
            manager.antiAliasing = (AntiAliasingSetting)EditorGUILayout.EnumPopup("Anti Aliasing", manager.antiAliasing);

            // Capture Options Section
            GUILayout.Label("Encoder Settings", EditorStyles.boldLabel);

            if (!manager.gpuEncoding)
            {
                manager.encoderPreset = (EncoderPreset)EditorGUILayout.EnumPopup("Encoder Preset", manager.encoderPreset);
            }
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (!FreeTrial.Check())
            {
                manager.gpuEncoding = EditorGUILayout.Toggle("GPU Encoding", manager.gpuEncoding);
            }
#endif

            serializedObject.Update();
            EditorGUILayout.PropertyField(videoCaptures, new GUIContent("Video Captures"), true);
            // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();

            //// Tools Section
            //GUILayout.Label("Tools", EditorStyles.boldLabel);
            GUILayout.Space(10);

            if (GUILayout.Button("Browse"))
            {
                // Open video save directory
                Utils.BrowseFolder(manager.saveFolder);
            }

            GUILayout.Space(10);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
コード例 #5
0
ファイル: ScreenShot.cs プロジェクト: tcdanielh/tilt-brush
        /// <summary>
        /// Initialize the attributes of the capture session and start capture.
        /// </summary>
        public bool StartCapture()
        {
            if (_captureStarted)
            {
                Debug.LogWarningFormat(LOG_FORMAT, "Previous screenshot session not finish yet!");
                OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.SCREENSHOT_ALREADY_IN_PROGRESS));
                return(false);
            }

            saveFolderFullPath = Utils.CreateFolder(saveFolder);

            if (captureMode == CaptureMode._360)
            {
                if (projectionType == ProjectionType.NONE)
                {
                    Debug.LogFormat(LOG_FORMAT,
                                    "Projection type should be set for 360 capture, set type to equirect for generating texture properly");
                    projectionType = ProjectionType.EQUIRECT;
                }
                if (projectionType == ProjectionType.CUBEMAP)
                {
                    if (stereoMode != StereoMode.NONE)
                    {
                        Debug.LogFormat(LOG_FORMAT,
                                        "Stereo settings not support for cubemap capture, reset to mono video capture.");
                        stereoMode = StereoMode.NONE;
                    }
                }
                CubemapSizeSettings();
            }
            else if (captureMode == CaptureMode.REGULAR)
            {
                // Non 360 capture doesn't have projection type
                projectionType = ProjectionType.NONE;
            }

            AntiAliasingSettings();

            // init ffmpeg encoding settings
            FFmpegEncoderSettings();

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (gpuEncoding)
            {
                if (FreeTrial.Check())
                {
                    Debug.LogFormat(LOG_FORMAT, "GPU encoding is not supported in free trial version, fall back to software encoding.");
                    gpuEncoding = false;
                }

                // init GPU encoding settings
                GPUEncoderSettings();

                if (!gpuEncoder.instantiated || !gpuEncoder.IsSupported())
                {
                    Debug.LogFormat(LOG_FORMAT, "GPU encoding is not supported in current device or settings, fall back to software encoding.");
                    gpuEncoding = false;
                }
            }
#else
            if (gpuEncoding)
            {
                Debug.LogFormat(LOG_FORMAT, "GPU encoding is only available on windows system, fall back to software encoding.");
                gpuEncoding = false;
            }
#endif

            if (gpuEncoding)
            {
                // init hardware encoding settings
                GPUEncoderSettings();

                if (!gpuEncoder.StartScreenShot())
                {
                    OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.SCREENSHOT_START_FAILED));
                    return(false);
                }
            }
            else
            {
                if (!ffmpegEncoder.StartScreenShot())
                {
                    OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.SCREENSHOT_START_FAILED));
                    return(false);
                }
            }

            _captureStarted = true;

            // Start garbage collect thread.
            //if (!garbageThreadRunning)
            //{
            //  garbageThreadRunning = true;

            //  if (garbageCollectionThread != null &&
            //    garbageCollectionThread.IsAlive)
            //  {
            //    garbageCollectionThread.Abort();
            //    garbageCollectionThread = null;
            //  }

            //  garbageCollectionThread = new Thread(GarbageCollectionProcess);
            //  garbageCollectionThread.Priority = System.Threading.ThreadPriority.Lowest;
            //  garbageCollectionThread.IsBackground = true;
            //  garbageCollectionThread.Start();
            //}

            Debug.LogFormat(LOG_FORMAT, "Screen shot session started.");
            return(true);
        }