I am programming an application for the HoloLens using Unity. In the application I want a button, which records an image when clicked. In order to take a picture I try to use Unitys PhotoCapture (as described here: https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.PhotoCapture.html or here: https://learn.microsoft.com/en-us/windows/mixed-reality/locatable-camera-in-unity).
When I run the Code and click the button following error appears: System.InvalidOperationException: 'Sequence contains no elements'
regarding following line: cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
Through Debugging I found that SupportedResolutions
is empty. How can I fix this?
Rest of code:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.XR.WSA.WebCam;
using UnityEngine.XR.WSA.Input;
using HoloToolkit.Unity.InputModule;
public class Record : MonoBehaviour, IInputClickHandler {
PhotoCapture photoCaptureObject = null;
Resolution cameraResolution;
void Start () {}
public void OnInputClicked(InputClickedEventData eventData)
{
cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
// Create a PhotoCapture object and so on
}
(Microphone and Webcam are enabled in Unity as input)