private void DrawConfigGUI() { EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(_lastCapturePath)); if (GUILayout.Button("Open Last Video")) { if (!ShowInExplorer(_lastCapturePath)) { _lastCapturePath = string.Empty; } } EditorGUI.EndDisabledGroup(); _expandConfig = EditorGUILayout.Foldout(_expandConfig, "Configure"); if (_expandConfig) { GUILayout.Label("General", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); EditorGUI.indentLevel++; _captureModeIndex = EditorGUILayout.Popup("Mode", _captureModeIndex, _captureModes); // Source EditorGUILayout.LabelField("Source", EditorStyles.boldLabel); EditorGUI.indentLevel++; _sourceType = (SourceType)EditorGUILayout.EnumPopup("Type", _sourceType); if (_sourceType == SourceType.Camera) { if (_cameraNode == null && Camera.main != null) { _cameraNode = Camera.main; } _cameraNode = (Camera)EditorGUILayout.ObjectField("Camera", _cameraNode, typeof(Camera), true); _cameraFastPixel = EditorGUILayout.Toggle("Fast Pixel Format", _cameraFastPixel); } EditorGUI.indentLevel--; // File name EditorGUILayout.LabelField("File Name", EditorStyles.boldLabel); EditorGUI.indentLevel++; _autoFilenamePrefixFromSceneName = EditorGUILayout.Toggle("From Scene Name", _autoFilenamePrefixFromSceneName); if (_autoFilenamePrefixFromSceneName) { _autoFilenamePrefix = System.IO.Path.GetFileNameWithoutExtension(EditorApplication.currentScene); if (string.IsNullOrEmpty(_autoFilenamePrefix)) { _autoFilenamePrefix = "capture"; } } EditorGUI.BeginDisabledGroup(_autoFilenamePrefixFromSceneName); _autoFilenamePrefix = EditorGUILayout.TextField("Prefix", _autoFilenamePrefix); EditorGUI.EndDisabledGroup(); _autoFilenameExtension = EditorGUILayout.TextField("Extension", _autoFilenameExtension); _appendTimestamp = EditorGUILayout.Toggle("Append Timestamp", _appendTimestamp); EditorGUI.indentLevel--; // File path EditorGUILayout.LabelField("File Path", EditorStyles.boldLabel); EditorGUI.indentLevel++; _outputFolderIndex = EditorGUILayout.Popup("Relative to", _outputFolderIndex, _outputFolders); if (_outputFolderIndex == 0) { _outputFolderRelative = EditorGUILayout.TextField("SubFolder(s)", _outputFolderRelative); } else { EditorGUILayout.BeginHorizontal(); _outputFolderAbsolute = EditorGUILayout.TextField("Path", _outputFolderAbsolute); if (GUILayout.Button(">", GUILayout.Width(22))) { _outputFolderAbsolute = EditorUtility.SaveFolderPanel("Select Folder To Store Video Captures", System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, "../")), ""); EditorUtility.SetDirty(this); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); GUILayout.Label("Video", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); EditorGUI.indentLevel++; if (_sourceType == 0) { // We can't just use Screen.width and Screen.height because Unity returns the size of this window // So instead we look for a camera with no texture target and a valid viewport int inWidth = 1; int inHeight = 1; foreach (Camera cam in Camera.allCameras) { if (cam.targetTexture == null) { float rectWidth = Mathf.Clamp01(cam.rect.width + cam.rect.x) - Mathf.Clamp01(cam.rect.x); float rectHeight = Mathf.Clamp01(cam.rect.height + cam.rect.y) - Mathf.Clamp01(cam.rect.y); if (rectWidth > 0.0f && rectHeight > 0.0f) { inWidth = Mathf.FloorToInt(cam.pixelWidth / rectWidth); inHeight = Mathf.FloorToInt(cam.pixelHeight / rectHeight); //Debug.Log (rectWidth + " " + (cam.rect.height - cam.rect.y) + " " + cam.pixelHeight + " = " + inWidth + "x" + inHeight); } break; } } Vector2 outSize = AVProMovieCaptureBase.GetRecordingResolution(inWidth, inHeight, GetDownScaleFromIndex(_downScaleIndex), new Vector2(_downscaleX, _downscaleY)); EditorGUILayout.LabelField("Output", (int)outSize.x + " x " + (int)outSize.y + " @ " + (int)_frameRate, EditorStyles.boldLabel); } else { if (_cameraNode) { int inWidth = Mathf.FloorToInt(_cameraNode.pixelRect.width); int inHeight = Mathf.FloorToInt(_cameraNode.pixelRect.height); Vector2 outSize = AVProMovieCaptureBase.GetRecordingResolution(inWidth, inHeight, GetDownScaleFromIndex(_downScaleIndex), new Vector2(_downscaleX, _downscaleY)); EditorGUILayout.LabelField("Output", (int)outSize.x + " x " + (int)outSize.y + " @ " + (int)_frameRate, EditorStyles.boldLabel); } } _downScaleIndex = EditorGUILayout.Popup("Down Scale", _downScaleIndex, _downScales); if (_downScaleIndex == 5) { Vector2 maxVideoSize = new Vector2(_downscaleX, _downscaleY); maxVideoSize = EditorGUILayout.Vector2Field("Size", maxVideoSize); _downscaleX = Mathf.Clamp((int)maxVideoSize.x, 1, 4096); _downscaleY = Mathf.Clamp((int)maxVideoSize.y, 1, 4096); } _frameRate = (AVProMovieCaptureBase.FrameRate)EditorGUILayout.EnumPopup("Frame Rate", _frameRate); if (ShowConfigList("Codec", _videoCodecNames, _videoCodecConfigurable, ref _videoCodecIndex)) { _queueConfigureVideoCodec = Mathf.Max(-1, _videoCodecIndex - 2); } EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); EditorGUI.BeginDisabledGroup(_captureModeIndex != 0); GUILayout.Label("Audio", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); EditorGUI.indentLevel++; _captureAudio = EditorGUILayout.Toggle("Capture Audio", _captureAudio); EditorGUI.BeginDisabledGroup(!_captureAudio); if (ShowConfigList("Source", _audioDeviceNames, null, ref _audioDeviceIndex, false)) { } if (ShowConfigList("Codec", _audioCodecNames, _audioCodecConfigurable, ref _audioCodecIndex)) { _queueConfigureAudioCodec = Mathf.Max(-1, _audioCodecIndex - 2); } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); EditorGUI.EndDisabledGroup(); GUILayout.Space(16f); if (GUILayout.Button("Reset Settings")) { ResetSettings(); } GUILayout.Space(4f); } }