Skip to content

Instantly share code, notes, and snippets.

@the6th
Last active May 22, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the6th/8134be25d431c2eb6b52e00613d66a03 to your computer and use it in GitHub Desktop.
Save the6th/8134be25d431c2eb6b52e00613d66a03 to your computer and use it in GitHub Desktop.
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