private void CreateComponents() { switch (_sourceType) { case SourceType.Scene: _captureScene = (AVProMovieCaptureFromScene)GameObject.FindObjectOfType(typeof(AVProMovieCaptureFromScene)); if (_captureScene == null) { GameObject go = new GameObject(TempGameObjectName); _captureScene = go.AddComponent <AVProMovieCaptureFromScene>(); } _capture = _captureScene; break; case SourceType.Camera: _captureCamera = _cameraNode.gameObject.GetComponent <AVProMovieCaptureFromCamera>(); if (_captureCamera == null) { _captureCamera = _cameraNode.gameObject.AddComponent <AVProMovieCaptureFromCamera>(); } _captureCamera._useFastPixelFormat = _cameraFastPixel; _capture = _captureCamera; break; } _audioCapture = null; if (_captureAudio && _audioDeviceIndex == 0) { _audioCapture = (AVProUnityAudioCapture)GameObject.FindObjectOfType(typeof(AVProUnityAudioCapture)); if (_audioCapture == null && Camera.main != null) { _audioCapture = Camera.main.gameObject.AddComponent <AVProUnityAudioCapture>(); } } }
private void StopCapture() { if (_capture != null) { if (_capture.IsCapturing()) { _capture.StopCapture(); _lastCapturePath = _capture.LastFilePath; } _capture = null; _captureScene = null; _captureCamera = null; } _audioCapture = null; }
private void CreateComponents() { switch (_sourceType) { case SourceType.Scene: _captureScene = (AVProMovieCaptureFromScene)GameObject.FindObjectOfType(typeof(AVProMovieCaptureFromScene)); if (_captureScene == null) { GameObject go = new GameObject(TempGameObjectName); _captureScene = go.AddComponent<AVProMovieCaptureFromScene>(); } _capture = _captureScene; break; case SourceType.Camera: _captureCamera = _cameraNode.gameObject.GetComponent<AVProMovieCaptureFromCamera>(); if (_captureCamera == null) { _captureCamera = _cameraNode.gameObject.AddComponent<AVProMovieCaptureFromCamera>(); } _captureCamera._useFastPixelFormat = _cameraFastPixel; _capture = _captureCamera; break; } _audioCapture = null; if (_captureAudio && _audioDeviceIndex == 0) { _audioCapture = (AVProUnityAudioCapture)GameObject.FindObjectOfType(typeof(AVProUnityAudioCapture)); if (_audioCapture == null && Camera.main != null) { _audioCapture = Camera.main.gameObject.AddComponent<AVProUnityAudioCapture>(); } } }
public override void OnInspectorGUI() { _capture = (this.target) as AVProMovieCaptureFromCamera; DrawDefaultInspector(); GUILayout.Space(8.0f); if (Application.isPlaying) { if (!_capture.IsCapturing()) { if (GUILayout.Button("Start Recording")) { _capture.SelectCodec(false); _capture.SelectAudioDevice(false); // We have to queue the start capture otherwise Screen.width and height aren't correct _capture.QueueStartCapture(); } } else { GUILayout.BeginHorizontal(); if (_capture._frameTotal > (int)_capture._frameRate * 2) { Color originalColor = GUI.color; float fpsDelta = Mathf.Abs(_capture._fps - (int)_capture._frameRate); GUI.color = Color.red; if (fpsDelta < 10) GUI.color = Color.yellow; if (fpsDelta < 2) GUI.color = Color.green; GUILayout.Label("Recording at " + _capture._fps.ToString("F1") + " fps"); GUI.color = originalColor; } else { GUILayout.Label("Recording at ... fps"); } if (!_capture.IsPaused()) { if (GUILayout.Button("Pause Capture")) { _capture.PauseCapture(); } } else { if (GUILayout.Button("Resume Capture")) { _capture.ResumeCapture(); } } if (GUILayout.Button("Stop Recording")) { _capture.StopCapture(); } GUILayout.EndHorizontal(); GUILayout.Space(8.0f); GUILayout.Label("Recording at: " + _capture.GetRecordingWidth() + "x" + _capture.GetRecordingHeight() + " @ " + ((int)_capture._frameRate).ToString() + "fps"); GUILayout.Space(8.0f); GUILayout.Label("Using video codec: '" + _capture._codecName + "'"); GUILayout.Label("Using audio device: '" + _capture._audioDeviceName + "'"); } } }
public override void OnInspectorGUI() { _capture = (this.target) as AVProMovieCaptureFromCamera; DrawDefaultInspector(); GUILayout.Space(8.0f); if (Application.isPlaying) { if (!_capture.IsCapturing()) { if (GUILayout.Button("Start Recording")) { _capture.SelectCodec(false); _capture.SelectAudioDevice(false); // We have to queue the start capture otherwise Screen.width and height aren't correct _capture.QueueStartCapture(); } } else { GUILayout.BeginHorizontal(); if (_capture._frameTotal > (int)_capture._frameRate * 2) { Color originalColor = GUI.color; float fpsDelta = Mathf.Abs(_capture._fps - (int)_capture._frameRate); GUI.color = Color.red; if (fpsDelta < 10) { GUI.color = Color.yellow; } if (fpsDelta < 2) { GUI.color = Color.green; } GUILayout.Label("Recording at " + _capture._fps.ToString("F1") + " fps"); GUI.color = originalColor; } else { GUILayout.Label("Recording at ... fps"); } if (!_capture.IsPaused()) { if (GUILayout.Button("Pause Capture")) { _capture.PauseCapture(); } } else { if (GUILayout.Button("Resume Capture")) { _capture.ResumeCapture(); } } if (GUILayout.Button("Stop Recording")) { _capture.StopCapture(); } GUILayout.EndHorizontal(); GUILayout.Space(8.0f); GUILayout.Label("Recording at: " + _capture.GetRecordingWidth() + "x" + _capture.GetRecordingHeight() + " @ " + ((int)_capture._frameRate).ToString() + "fps"); GUILayout.Space(8.0f); GUILayout.Label("Using video codec: '" + _capture._codecName + "'"); GUILayout.Label("Using audio device: '" + _capture._audioDeviceName + "'"); } } }
// Use this for initialization void Start() { recorderScript = recorderCam.GetComponent <AVProMovieCaptureFromCamera>(); }