Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HoloLens Unityアプリで、カメラへの許可がされているか確認する https://littlewing.hatenablog.com/entry/2018/12/21/191656
#if !UNITY_EDITOR && UNITY_WSA
using Windows.Media.Capture;
#endif
class Hoge:MonoBehaviour
{
#if !UNITY_EDITOR && UNITY_WSA
public async void funcA()
{
MediaCapture _mediaCapture = new MediaCapture();
try
{
await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
{
//これが無いとmicrophoneの権限まで確認してしまう。
StreamingCaptureMode = StreamingCaptureMode.Video
});
//正常処理
Debug.Log("camera is enable.Go next on UWP");
}
catch (UnauthorizedAccessException ex)
{
Debug.Log("カメラへのアクセス権限を有効にしてください。");
}
}
#else
public void funcA()
{
//正常処理
Debug.Log("Go next on Editor")
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.