Exemplo n.º 1
0
 private void OnGUI()
 {
     if (VideoCaptureCtrl.instance.status == VideoCaptureCtrl.StatusType.NOT_START)
     {
         if (GUI.Button(new Rect(10, Screen.height - 60, 150, 50), "Start Capture"))
         {
             VideoCaptureCtrl.instance.StartCapture();
         }
     }
     else if (VideoCaptureCtrl.instance.status == VideoCaptureCtrl.StatusType.STARTED)
     {
         if (GUI.Button(new Rect(10, Screen.height - 60, 150, 50), "Stop Capture"))
         {
             VideoCaptureCtrl.instance.StopCapture();
         }
         if (GUI.Button(new Rect(180, Screen.height - 60, 150, 50), "Pause Capture"))
         {
             VideoCaptureCtrl.instance.ToggleCapture();
         }
     }
     else if (VideoCaptureCtrl.instance.status == VideoCaptureCtrl.StatusType.PAUSED)
     {
         if (GUI.Button(new Rect(10, Screen.height - 60, 150, 50), "Stop Capture"))
         {
             VideoCaptureCtrl.instance.StopCapture();
         }
         if (GUI.Button(new Rect(180, Screen.height - 60, 150, 50), "Continue Capture"))
         {
             VideoCaptureCtrl.instance.ToggleCapture();
         }
     }
     else if (VideoCaptureCtrl.instance.status == VideoCaptureCtrl.StatusType.STOPPED)
     {
         if (GUI.Button(new Rect(10, Screen.height - 60, 150, 50), "Processing"))
         {
             // Waiting processing end.
         }
     }
     else if (VideoCaptureCtrl.instance.status == VideoCaptureCtrl.StatusType.FINISH)
     {
         if (GUI.Button(new Rect(10, Screen.height - 60, 150, 50), "Open Video Folder"))
         {
             // Open video save directory.
             FunctionUtils.OpenSaveFolder();
         }
     }
 }
        public override void OnInspectorGUI()
        {
            VideoCapture videoCapture = (VideoCapture)target;

            GUILayout.BeginVertical("box");
            GUILayout.Label("Capture Mode");
            videoCapture.mode = (VideoCapture.ModeType)EditorGUILayout.EnumPopup("Mode", videoCapture.mode);

            //if (videoCapture.mode == VideoCapture.ModeType.LIVE_STREAMING)
            //{
            //  videoCapture.streamingAddress = EditorGUILayout.TextField("Streaming Server Address", videoCapture.streamingAddress);
            //}
            //else
            //{
            videoCapture.customPath = EditorGUILayout.Toggle(new GUIContent("Use Custom Path", "Use external folder Path"), videoCapture.customPath);
            if (videoCapture.customPath)
            {
                videoCapture.customPathFolder = EditorGUILayout.TextField("Custom Path Folder", videoCapture.customPathFolder);
                PathConfig.SaveFolder         = videoCapture.customPathFolder + @"\";
            }
            else
            {
                PathConfig.SaveFolder = "";
            }
            GUILayout.Label(PathConfig.SaveFolder);
            //}
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            GUILayout.Label("Capture Format");
            videoCapture.format = (VideoCapture.FormatType)EditorGUILayout.EnumPopup("Format", videoCapture.format);
            if (videoCapture.format == VideoCapture.FormatType.NORMAL)
            {
                if (videoCapture.isDedicated)
                {
                    videoCapture.frameSize = (VideoCapture.FrameSizeType)EditorGUILayout.EnumPopup("Frame Size", videoCapture.frameSize);
                }
            }
            else if (videoCapture.format == VideoCapture.FormatType.PANORAMA)
            {
                GUILayout.BeginVertical("box");
                GUILayout.Label("Projection Format");
                videoCapture.panoramaProjection = (VideoCapture.PanoramaProjectionType)EditorGUILayout.EnumPopup("Projection Type", videoCapture.panoramaProjection);
                if (videoCapture.panoramaProjection == VideoCapture.PanoramaProjectionType.EQUIRECTANGULAR)
                {
                    videoCapture.frameSize = (VideoCapture.FrameSizeType)EditorGUILayout.EnumPopup("Frame Size", videoCapture.frameSize);
                }
                videoCapture._cubemapSize = (VideoCapture.CubemapSizeType)EditorGUILayout.EnumPopup("Cubemap Size", videoCapture._cubemapSize);
                GUILayout.EndVertical();
                videoCapture.captureGUI = EditorGUILayout.Toggle("Capture GUI", videoCapture.captureGUI);
            }
            videoCapture.stereo = (VideoCapture.StereoType)EditorGUILayout.EnumPopup("Stereo Format", videoCapture.stereo);
            if (videoCapture.stereo != VideoCapture.StereoType.NONE)
            {
                GUILayout.BeginVertical("box");
                GUILayout.Label("Stereo Format");
                videoCapture.stereoFormat           = (VideoCapture.StereoFormatType)EditorGUILayout.EnumPopup("Stereo Format Type", videoCapture.stereoFormat);
                videoCapture.interPupillaryDistance = EditorGUILayout.FloatField("Inter Pupillary Distance", videoCapture.interPupillaryDistance);
                GUILayout.EndVertical();
            }
            videoCapture.offlineRender    = EditorGUILayout.Toggle("Offline Render", videoCapture.offlineRender);
            videoCapture.encodeQuality    = (VideoCapture.EncodeQualityType)EditorGUILayout.EnumPopup("Encode Quality", videoCapture.encodeQuality);
            videoCapture._antiAliasing    = (VideoCapture.AntiAliasingType)EditorGUILayout.EnumPopup("Anti Aliasing", videoCapture._antiAliasing);
            videoCapture._targetFramerate = (VideoCapture.TargetFramerateType)EditorGUILayout.EnumPopup("Target FrameRate", videoCapture._targetFramerate);
            videoCapture.isDedicated      = EditorGUILayout.Toggle("Dedicated Camera", videoCapture.isDedicated);
            if (GUILayout.Button("Re-Encode Video Resolution to 4K"))
            {
                FunctionUtils.EncodeVideo4K(PathConfig.lastVideoFile);
            }
            if (GUILayout.Button("Generate GIF Image"))
            {
                FunctionUtils.ConvertVideoGif(PathConfig.lastVideoFile);
            }
            if (GUILayout.Button("Open Save folder"))
            {
                FunctionUtils.OpenSaveFolder();
            }
            GUILayout.EndVertical();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
//#if UNITY_5_4_OR_NEWER
//        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
//#endif
            }
        }