private static AVProLiveCameraDeviceMode GetClosestMode(AVProLiveCameraDevice device, List <Vector2> resolutions, bool maintainApectRatio) { AVProLiveCameraDeviceMode result = null; for (int i = 0; i < resolutions.Count; i++) { result = device.GetClosestMode(Mathf.FloorToInt(resolutions[i].x), Mathf.FloorToInt(resolutions[i].y), maintainApectRatio); if (result != null) { break; } } return(result); }
private void EnumModes() { int numModes = AVProLiveCameraPlugin.GetNumModes(_deviceIndex); for (int i = 0; i < numModes; i++) { int width, height; float fps; string format; if (AVProLiveCameraPlugin.GetModeInfo(_deviceIndex, i, out width, out height, out fps, out format)) { AVProLiveCameraDeviceMode mode = new AVProLiveCameraDeviceMode(this, i, width, height, fps, format.ToString()); _modes.Add(mode); } } }
public void Begin() { SelectDeviceAndMode(); if (_device != null) { _device.Deinterlace = _deinterlace; if (!_device.Start(_mode, _videoInput)) { Debug.LogWarning("[AVPro Live Camera] Device failed to start."); _device.Close(); _device = null; _mode = null; _videoInput = -1; } } }
public void SelectDeviceAndMode() { _device = null; _mode = null; _videoInput = -1; _device = SelectDevice(); if (_device != null) { _mode = SelectMode(); _videoInput = SelectVideoInputIndex(); } else { Debug.LogWarning("[AVPro Live Camera] Could not find the device."); } }
public bool Start(int modeIndex = -1, int videoInputIndex = -1) { AVProLiveCameraDeviceMode mode = null; if (modeIndex >= 0) { if (modeIndex < _modes.Count) { mode = _modes[modeIndex]; } else { Debug.LogError("[AVProLiveCamera] Mode index out of range, using default resolution"); } } return(Start(mode, videoInputIndex)); }
public AVProLiveCameraDeviceMode GetHighestResolutionMode(float minimumFrameRate) { AVProLiveCameraDeviceMode result = null; float highestRes = 0f; for (int i = 0; i < NumModes; i++) { AVProLiveCameraDeviceMode mode = GetMode(i); if (mode.FPS >= minimumFrameRate && (mode.Width * mode.Height > highestRes)) { result = mode; highestRes = mode.Width * mode.Height; } } return(result); }
void Reset() { _videoInput = -1; _mode = null; _device = null; _deviceSelection = SelectDeviceBy.Default; _modeSelection = SelectModeBy.Default; _videoInputSelection = SelectDeviceBy.Default; _desiredDeviceNames = new List <string>(4); _desiredResolutions = new List <Vector2>(2); _desiredVideoInputs = new List <AVProLiveCameraPlugin.VideoInput>(4); _desiredDeviceNames.Add("Decklink Video Capture"); _desiredDeviceNames.Add("Logitech Webcam Pro 9000"); _desiredResolutions.Add(new Vector2(640, 360)); _desiredResolutions.Add(new Vector2(1280, 720)); _desiredVideoInputs.Add(AVProLiveCameraPlugin.VideoInput.Video_Serial_Digital); _desiredVideoInputs.Add(AVProLiveCameraPlugin.VideoInput.Video_SVideo); _desiredVideoInputIndex = 0; _maintainAspectRatio = false; _desiredModeIndex = -1; _desiredDeviceIndex = 0; }
private AVProLiveCameraDeviceMode SelectMode() { AVProLiveCameraDeviceMode result = null; switch (_modeSelection) { default: case SelectModeBy.Default: result = null; break; case SelectModeBy.Resolution: if (_desiredResolutions.Count > 0) { result = GetClosestMode(_device, _desiredResolutions, _maintainAspectRatio); if (result == null) { Debug.LogWarning("[AVPro Live Camera] Could not find desired mode, using default mode."); } } break; case SelectModeBy.Index: if (_desiredModeIndex >= 0) { result = _device.GetMode(_desiredModeIndex); if (result == null) { Debug.LogWarning("[AVPro Live Camera] Could not find desired mode, using default mode."); } } break; } return(result); }
public void OnGUI() { if (_guiSkin != null) { if (_buttonStyle == null) { _buttonStyle = _guiSkin.FindStyle("LeftButton"); } GUI.skin = _guiSkin; } if (_buttonStyle == null) { _buttonStyle = GUI.skin.button; } _horizScrollPos = GUILayout.BeginScrollView(_horizScrollPos, false, false); GUILayout.BeginHorizontal(); for (int i = 0; i < AVProLiveCameraManager.Instance.NumDevices; i++) { GUILayout.BeginVertical("box", GUILayout.MaxWidth(300)); AVProLiveCameraDevice device = AVProLiveCameraManager.Instance.GetDevice(i); GUI.enabled = device.IsConnected; Rect cameraRect = GUILayoutUtility.GetRect(300, 168); if (GUI.Button(cameraRect, "")) { if (_zoomed == null) { _zoomed = device.OutputTexture; _zoomSrcDest = cameraRect; _zoomUp = true; } } // Thumbnail image if (device.OutputTexture != null && _zoomed != device.OutputTexture) { if (_material != null) { DrawTexture(cameraRect, device.OutputTexture, ScaleMode.ScaleToFit, _material); } else { GUI.DrawTexture(cameraRect, device.OutputTexture, ScaleMode.ScaleToFit, false); } } GUILayout.Box("Camera " + i + ": " + device.Name); if (!device.IsRunning) { GUILayout.BeginHorizontal(); GUI.color = Color.green; if (GUILayout.Button("Start")) { if (_zoomed == null) { device.Start(-1); } } GUI.color = Color.white; } else { GUILayout.Box(string.Format("{0}x{1} {2}", device.CurrentWidth, device.CurrentHeight, device.CurrentFormat)); GUILayout.BeginHorizontal(); GUILayout.Box(string.Format("Capture {0}hz Display {1}hz", device.CaptureFPS.ToString("F2"), device.DisplayFPS.ToString("F2"))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("Stop")) { if (_zoomed == null) { device.Close(); } } GUI.color = Color.white; } GUI.enabled = device.CanShowConfigWindow(); if (GUILayout.Button("Configure", GUILayout.ExpandWidth(false))) { if (_zoomed == null) { device.ShowConfigWindow(); } } GUI.enabled = true; GUILayout.EndHorizontal(); if (device.NumVideoInputs > 0) { GUILayout.Label("Select a video input:"); _scrollVideoInputPos[i] = GUILayout.BeginScrollView(_scrollVideoInputPos[i], false, false); for (int j = 0; j < device.NumVideoInputs; j++) { if (GUILayout.Button(device.GetVideoInputName(j))) { if (_zoomed == null) { // Start selected device device.Close(); device.Start(-1, j); } } } GUILayout.EndScrollView(); } if (device.Deinterlace != GUILayout.Toggle(device.Deinterlace, "Deinterlace", GUILayout.ExpandWidth(true))) { device.Deinterlace = !device.Deinterlace; if (device.IsRunning) { device.Close(); device.Start(-1, -1); } } GUILayout.BeginHorizontal(); device.FlipX = GUILayout.Toggle(device.FlipX, "Flip X", GUILayout.ExpandWidth(true)); device.FlipY = GUILayout.Toggle(device.FlipY, "Flip Y", GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); _scrollPos[i] = GUILayout.BeginScrollView(_scrollPos[i], false, false); if (device.NumSettings > 0) { GUI.color = Color.cyan; _showSettings[i] = GUILayout.Toggle(_showSettings[i], "Settings ▶", GUILayout.ExpandWidth(true)); GUI.color = Color.white; if (_showSettings[i]) { device.UpdateSettings = GUILayout.Toggle(device.UpdateSettings, "Update Settings", GUILayout.ExpandWidth(true)); for (int j = 0; j < device.NumSettings; j++) { AVProLiveCameraSettingBase settingBase = device.GetVideoSettingByIndex(j); GUILayout.BeginHorizontal(); GUI.enabled = !settingBase.IsAutomatic; if (GUILayout.Button("D", GUILayout.ExpandWidth(false))) { settingBase.SetDefault(); } GUI.enabled = true; GUILayout.Label(settingBase.Name, GUILayout.ExpandWidth(false)); GUI.enabled = !settingBase.IsAutomatic; switch (settingBase.DataTypeValue) { case AVProLiveCameraSettingBase.DataType.Boolean: AVProLiveCameraSettingBoolean settingBool = (AVProLiveCameraSettingBoolean)settingBase; settingBool.CurrentValue = GUILayout.Toggle(settingBool.CurrentValue, "", GUILayout.ExpandWidth(true)); break; case AVProLiveCameraSettingBase.DataType.Float: AVProLiveCameraSettingFloat settingFloat = (AVProLiveCameraSettingFloat)settingBase; settingFloat.CurrentValue = GUILayout.HorizontalSlider(settingFloat.CurrentValue, settingFloat.MinValue, settingFloat.MaxValue, GUILayout.ExpandWidth(true)); GUI.enabled = settingBase.CanAutomatic; settingBase.IsAutomatic = GUILayout.Toggle(settingBase.IsAutomatic, "", GUILayout.Width(32.0f)); GUI.enabled = true; break; } GUI.enabled = true; GUILayout.EndHorizontal(); } if (GUILayout.Button("Defaults")) { for (int j = 0; j < device.NumSettings; j++) { AVProLiveCameraSettingBase settingBase = device.GetVideoSettingByIndex(j); settingBase.SetDefault(); } } } } GUI.color = Color.cyan; _showModes[i] = GUILayout.Toggle(_showModes[i], "Modes ▶", GUILayout.ExpandWidth(true)); GUI.color = Color.white; if (_showModes[i]) { for (int j = 0; j < device.NumModes; j++) { AVProLiveCameraDeviceMode mode = device.GetMode(j); if (GUILayout.Button("" + mode.Width + "x" + mode.Height + " " + mode.FPS.ToString("F2") + "hz " + "[" + mode.Format + "]", _buttonStyle)) { if (_zoomed == null) { // Start selected device device.Close(); Debug.Log("Selecting mode: " + j); device.Start(mode); } } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); // Show zoomed camera image if (_zoomed != null) { Rect fullScreenRect = new Rect(0f, 0f, Screen.width, Screen.height); float t = Mathf.Clamp01(_zoomTimer / ZoomTime); t = Mathf.SmoothStep(0f, 1f, t); Rect r = new Rect(); r.x = Mathf.Lerp(_zoomSrcDest.x, fullScreenRect.x, t); r.y = Mathf.Lerp(_zoomSrcDest.y, fullScreenRect.y, t); r.width = Mathf.Lerp(_zoomSrcDest.width, fullScreenRect.width, t); r.height = Mathf.Lerp(_zoomSrcDest.height, fullScreenRect.height, t); if (_material != null) { DrawTexture(r, _zoomed, ScaleMode.ScaleToFit, _material); } else { GUI.DrawTexture(r, _zoomed, ScaleMode.ScaleToFit, false); } } }
public void Begin() { SelectDeviceAndMode(); if (_device != null) { _device.Deinterlace = _deinterlace; _device.FlipX = _flipX; _device.FlipY = _flipY; if (!_device.Start(_mode, _videoInput)) { Debug.LogWarning("[AVPro Live Camera] Device failed to start."); _device.Close(); _device = null; _mode = null; _videoInput = -1; } } }
void OnGUI() { if (_isHidden) { return; } GUI.skin = _guiSkin; if (_liveCameraManager.NumDevices > 0) { GUILayout.BeginArea(new Rect(0f, 0f, Screen.width, Screen.height)); if (GUILayout.Button("Press SPACE to hide/show QuickDeviceMenu (improves performance)", GUILayout.ExpandWidth(false))) { ToggleVisible(); } GUILayout.EndArea(); // NOTE: This is just a spacing element to leave space for the above message GUILayout.Label(" "); GUILayout.BeginHorizontal(); // Select device GUILayout.BeginVertical(); GUILayout.Button("SELECT DEVICE"); for (int i = 0; i < _liveCameraManager.NumDevices; i++) { string name = _liveCameraManager.GetDevice(i).Name; GUI.color = Color.white; if (_liveCamera.Device != null && _liveCamera.Device.IsRunning) { if (_liveCamera.Device.Name == name) { GUI.color = Color.green; } } if (GUILayout.Button(name)) { _liveCamera._deviceSelection = AVProLiveCamera.SelectDeviceBy.Index; _liveCamera._desiredDeviceIndex = i; _liveCamera.Begin(); } } GUI.color = Color.white; GUILayout.EndVertical(); if (_liveCamera.Device != null && _liveCamera.Device.IsRunning) { GUILayout.BeginVertical(); GUILayout.Button("RESOLUTION"); _scrollResolutions = GUILayout.BeginScrollView(_scrollResolutions, false, false, GUIStyle.none, GUI.skin.verticalScrollbar); List <string> usedNames = new List <string>(32); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string name = string.Format("{0}x{1}", mode.Width, mode.Height); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentWidth == mode.Width && _liveCamera.Device.CurrentHeight == mode.Height) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.EndVertical(); // Select frame rate usedNames.Clear(); GUILayout.BeginVertical(); GUILayout.Button("FPS"); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { string matchName = string.Format("{0}x{1}", _liveCamera.Device.CurrentWidth, _liveCamera.Device.CurrentHeight); AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string resName = string.Format("{0}x{1}", mode.Width, mode.Height); if (resName == matchName) { string name = string.Format("{0}", mode.FPS.ToString("F2")); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentFrameRate.ToString("F2") == mode.FPS.ToString("F2")) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } } GUI.color = Color.white; GUILayout.EndVertical(); // Select format usedNames.Clear(); GUILayout.BeginVertical(); GUILayout.Button("FORMAT"); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { string matchName = string.Format("{0}x{1}@", _liveCamera.Device.CurrentWidth, _liveCamera.Device.CurrentHeight, _liveCamera.Device.CurrentFrameRate.ToString("F2")); AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string resName = string.Format("{0}x{1}@", mode.Width, mode.Height, mode.FPS.ToString("F2")); if (resName == matchName) { string name = string.Format("{0}", mode.Format); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentDeviceFormat == mode.Format) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } } GUI.color = Color.white; GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } else { GUILayout.Label("No webcam / capture devices found"); } }
public AVProLiveCameraDeviceMode GetClosestMode(int width, int height, bool maintainAspectRatio, bool highestFrameRate) { AVProLiveCameraDeviceMode result = null; if (width <= 0 || height <= 0) { return(result); } List <AVProLiveCameraDeviceMode> bestModes = new List <AVProLiveCameraDeviceMode>(); // Try to find exact match to resolution { for (int i = 0; i < NumModes; i++) { AVProLiveCameraDeviceMode mode = GetMode(i); if (mode.Width == width && mode.Height == height) { bestModes.Add(mode); } } } // If we haven't found an exact match, find by closest area if (bestModes.Count == 0) { float aspect = (float)width * (float)height; int area = width * height; float lowestAreaDifference = float.MaxValue; for (int i = 0; i < NumModes; i++) { AVProLiveCameraDeviceMode mode = GetMode(i); // Maintain aspect ratio or not float modeAspect = (float)mode.Width / (float)mode.Height; bool consider = true; if (maintainAspectRatio && !Mathf.Approximately(modeAspect, aspect)) { consider = false; } if (consider) { int modeArea = mode.Width * mode.Height; int areaDifference = Mathf.Abs(area - modeArea); if (areaDifference < lowestAreaDifference) { result = mode; lowestAreaDifference = areaDifference; } } } // Now that we know the closest resolution, collect all modes with that resolution if (result != null) { for (int i = 0; i < NumModes; i++) { AVProLiveCameraDeviceMode mode = GetMode(i); if (mode.Width == result.Width && mode.Height == result.Height) { bestModes.Add(mode); } } result = null; } } // Pick best based on pixel format or frame rate if (bestModes.Count > 0) { if (bestModes.Count == 1) { result = bestModes[0]; } else { if (highestFrameRate) { float highestFps = 0f; for (int i = 0; i < bestModes.Count; i++) { AVProLiveCameraDeviceMode mode = bestModes[i]; if (mode.FPS > highestFps) { highestFps = mode.FPS; result = mode; } } } else { string[] bestFormats = { "YUV_UYVY_HDYC", "YUV_UYVY", "YUV_YVYU", "YUV_YUY2", "ARGB32", "RGB32", "RGB24", "MJPG", "UNKNOWN" }; int bestScore = 100; for (int i = 0; i < bestModes.Count; i++) { int index = System.Array.IndexOf <string>(bestFormats, bestModes[i].Format); if (index >= 0 && index < bestScore) { result = bestModes[i]; bestScore = index; } } } } } if (result != null) { //Debug.Log(string.Format("Selected mode {0}: {1}x{2} {3} {4}", result.Index, result.Width , result.Height, result.FPS, result.Format)); } return(result); }
public bool Start(AVProLiveCameraDeviceMode mode, int videoInputIndex = -1) { // Resolve the internal mode index int internalModeIndex = -1; if (mode != null) { internalModeIndex = mode.InternalIndex; } // Start the device if (AVProLiveCameraPlugin.StartDevice(_deviceIndex, internalModeIndex, videoInputIndex)) { int modeIndex = -1; if (mode != null) { for (int i = 0; i < _modes.Count; i++) { if (_modes[i] == mode) { modeIndex = i; break; } } } Debug.Log("[AVProLiveCamera] Started device using mode index " + modeIndex + " (internal index " + internalModeIndex + ")"); // Get format mode properties int width = AVProLiveCameraPlugin.GetWidth(_deviceIndex); int height = AVProLiveCameraPlugin.GetHeight(_deviceIndex); AVProLiveCameraPlugin.VideoFrameFormat format = (AVProLiveCameraPlugin.VideoFrameFormat)AVProLiveCameraPlugin.GetFormat(_deviceIndex); _width = width; _height = height; _format = format.ToString(); _deviceFormat = AVProLiveCameraPlugin.GetDeviceFormat(_deviceIndex); _frameRate = AVProLiveCameraPlugin.GetFrameRate(_deviceIndex); _frameDurationHNS = AVProLiveCameraPlugin.GetFrameDurationHNS(_deviceIndex); // Validate properties if (width <= 0 || width > MaxVideoResolution || height <= 0 || height > MaxVideoResolution) { Debug.LogWarning("[AVProLiveCamera] invalid width or height"); Close(); return(false); } // Create format converter _isTopDown = AVProLiveCameraPlugin.IsFrameTopDown(_deviceIndex); if (!_formatConverter.Build(width, height, format, _flipX, _isTopDown != _flipY, Deinterlace)) { Debug.LogWarning("[AVProLiveCamera] unable to convert camera format"); Close(); return(false); } // Run camera IsActive = true; IsRunning = false; IsPicture = false; IsPaused = true; _lastModeIndex = modeIndex; _lastVideoInputIndex = videoInputIndex; Play(); return(IsRunning); } Debug.LogWarning("[AVProLiveCamera] unable to start camera"); Close(); return(false); }
public bool Start(AVProLiveCameraDeviceMode mode, int videoInputIndex = -1) { if (mode != null) return Start(mode.Index, videoInputIndex); return Start(); }
void Reset() { _videoInput = -1; _mode = null; _device = null; _flipX = _flipY = false; _deviceSelection = SelectDeviceBy.Default; _modeSelection = SelectModeBy.Default; _videoInputSelection = SelectDeviceBy.Default; _desiredDeviceNames = new List<string>(4); _desiredResolutions = new List<Vector2>(2); _desiredVideoInputs = new List<AVProLiveCameraPlugin.VideoInput>(4); _desiredDeviceNames.Add("Logitech HD Pro Webcam C920"); _desiredDeviceNames.Add("Decklink Video Capture"); _desiredDeviceNames.Add("Logitech Webcam Pro 9000"); _desiredResolutions.Add(new Vector2(1920, 1080)); _desiredResolutions.Add(new Vector2(1280, 720)); _desiredResolutions.Add(new Vector2(640, 360)); _desiredResolutions.Add(new Vector2(640, 480)); _desiredVideoInputs.Add(AVProLiveCameraPlugin.VideoInput.Video_Serial_Digital); _desiredVideoInputs.Add(AVProLiveCameraPlugin.VideoInput.Video_SVideo); _desiredVideoInputIndex = 0; _maintainAspectRatio = false; _desiredModeIndex = -1; _desiredDeviceIndex = 0; }
void OnGUI() { GUI.skin = _guiSkin; if (_liveCameraManager.NumDevices > 0) { GUILayout.BeginHorizontal(); // Select device GUILayout.BeginVertical(); GUILayout.Button("SELECT DEVICE"); for (int i = 0; i < _liveCameraManager.NumDevices; i++) { GUI.color = Color.white; if (_liveCamera._desiredDeviceIndex == i && _liveCamera.Device != null && _liveCamera.Device.IsRunning) { GUI.color = Color.green; } string name = _liveCameraManager.GetDevice(i).Name; if (GUILayout.Button(name)) { _liveCamera._deviceSelection = AVProLiveCamera.SelectDeviceBy.Index; _liveCamera._desiredDeviceIndex = i; _liveCamera.Begin(); } } GUI.color = Color.white; GUILayout.EndVertical(); if (_liveCamera.Device != null && _liveCamera.Device.IsRunning) { //Select resolution GUILayout.BeginVertical(); GUILayout.Button("RESOLUTION"); List <string> usedNames = new List <string>(32); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string name = string.Format("{0}x{1}", mode.Width, mode.Height); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentWidth == mode.Width && _liveCamera.Device.CurrentHeight == mode.Height) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } GUI.color = Color.white; GUILayout.EndVertical(); // Select frame rate usedNames.Clear(); GUILayout.BeginVertical(); GUILayout.Button("FPS"); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { string matchName = string.Format("{0}x{1}", _liveCamera.Device.CurrentWidth, _liveCamera.Device.CurrentHeight); AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string resName = string.Format("{0}x{1}", mode.Width, mode.Height); if (resName == matchName) { string name = string.Format("{0}", mode.FPS.ToString("F2")); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentFrameRate.ToString("F2") == mode.FPS.ToString("F2")) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } } GUI.color = Color.white; GUILayout.EndVertical(); // Select format usedNames.Clear(); GUILayout.BeginVertical(); GUILayout.Button("FORMAT"); for (int i = 0; i < _liveCamera.Device.NumModes; i++) { string matchName = string.Format("{0}x{1}@", _liveCamera.Device.CurrentWidth, _liveCamera.Device.CurrentHeight, _liveCamera.Device.CurrentFrameRate.ToString("F2")); AVProLiveCameraDeviceMode mode = _liveCamera.Device.GetMode(i); string resName = string.Format("{0}x{1}@", mode.Width, mode.Height, mode.FPS.ToString("F2")); if (resName == matchName) { string name = string.Format("{0}", mode.Format); if (!usedNames.Contains(name)) { GUI.color = Color.white; if (_liveCamera.Device.CurrentDeviceFormat == mode.Format) { GUI.color = Color.green; } usedNames.Add(name); if (GUILayout.Button(name)) { _liveCamera._modeSelection = AVProLiveCamera.SelectModeBy.Index; _liveCamera._desiredModeIndex = i; _liveCamera.Begin(); } } } } GUI.color = Color.white; GUILayout.EndVertical(); } } else { GUILayout.Label("No webcam / capture devices found"); } }