public void RenderExplorer() { if (!_showExplorer) { return; } bool restartDevice = false; if (_modeListStyle == null) { _modeListStyle = GUI.skin.GetStyle("ModeList"); } // List the devices GUILayout.BeginVertical("box", GUILayout.MinWidth(200), GUILayout.MaxHeight(200)); if (GUILayout.Button("Select Device")) { _deviceIndex = -1; _modeIndex = -1; restartDevice = true; } _deviceScrollPos = GUILayout.BeginScrollView(_deviceScrollPos, false, false); for (int i = 0; i < DeckLink.GetNumDevices(); i++) { Device device = DeckLink.GetDevice(i); if (device.DeviceIndex == _deviceIndex) { DeviceMode mode = IsInput() ? device.CurrentMode : device.CurrentOutputMode; if (mode != null && _modeIndex == mode.Index) { GUI.color = Color.green; } else { GUI.color = Color.blue; } } bool deviceValid = IsInput() ? device.CanInput() : device.CanOutput(); if (device.DeviceIndex == _deviceIndex || deviceValid) { if (GUILayout.Button(device.Name + " " + device.ModelName, _modeListStyle)) { if (_deviceIndex != device.DeviceIndex) { _deviceIndex = device.DeviceIndex; _modeIndex = -1; restartDevice = true; } } } GUI.color = Color.white; } GUILayout.EndScrollView(); GUILayout.EndVertical(); Device currDevice = DeckLink.GetDevice(_deviceIndex); if (currDevice != null) { GUILayout.BeginVertical("box", GUILayout.MinWidth(500), GUILayout.MaxHeight(200)); if (GUILayout.Button("Select Mode:")) { _modeIndex = -1; restartDevice = true; } _modeScrollPos = GUILayout.BeginScrollView(_modeScrollPos, false, false); int numModes = IsInput() ? currDevice.NumInputModes : currDevice.NumOutputModes; for (int j = 0; j < numModes; j++) { DeviceMode mode = IsInput() ? currDevice.GetInputMode(j) : currDevice.GetOutputMode(j); if (mode.Index == _modeIndex) { bool streamRunning = IsInput() ? currDevice.IsStreamingInput : currDevice.IsStreamingOutput; if (streamRunning) { GUI.color = Color.green; } else { GUI.color = Color.blue; } } if (GUILayout.Button("" + j.ToString("D2") + ") " + mode.ModeDescription + " - " + mode.PixelFormatDescription + " - " + mode.Width + "x" + mode.Height, _modeListStyle)) { if (mode.Index != _modeIndex) { _modeIndex = mode.Index; restartDevice = true; } } GUI.color = Color.white; } GUILayout.EndScrollView(); GUILayout.EndVertical(); } if (restartDevice) { Begin(); } }
protected override void BeginDevice() { _currCapturedFrame = 0; #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN _device.GenlockOffset = _genlockPixelOffset; if (_current3DEnabled) { if (!DeckLinkPlugin.IsOutputMode3DSupported(_deviceIndex, _modeIndex)) { _current3DEnabled = false; Debug.LogWarning("[AVProDeckLink] Output mode does not support stereo mode " + _modeIndex + ", disabling"); } } DeckLinkPlugin.Set3DPlaybackEnabled(_device.DeviceIndex, _current3DEnabled); _device.LowLatencyMode = _lowLatencyMode; // Set keying mode before the output has started, as this can affect buffer allocation sizes if (_keyerMode != KeyerMode.None) { _device.CurrentKeyingMode = _keyerMode; } // Try starting output if (!_device.StartOutput(_modeIndex)) { Debug.LogWarning("[AVProDeckLink] device failed to start."); StopOutput(); _device = null; } else { DeviceMode mode = _device.GetOutputMode(_modeIndex); RegisterAudioOutput(); float framerate = mode.FrameRate; InitCaptureBlendResources(mode.Width, mode.Height); if (mode.InterlacedFieldMode) { _interlaced = true; framerate *= 2; InitInterlaceResources(mode.Width, mode.Height); } else { _interlaced = false; } InitConversionResources(mode.PixelFormat, mode.Width, mode.Height); if (!DeckLinkSettings.Instance._multiOutput && !_syncedToInput) { Application.targetFrameRate = _targetFrameRate = Mathf.CeilToInt(framerate); #if !UNITY_2018_2_OR_NEWER Time.captureFramerate = _targetFrameRate; #endif } else { Application.targetFrameRate = Time.captureFramerate = -1; _outputFrameRate = _targetFrameRate = Mathf.CeilToInt(framerate); } AttachToCamera(); } #endif }