Last active
May 22, 2019 02:33
-
-
Save the6th/8134be25d431c2eb6b52e00613d66a03 to your computer and use it in GitHub Desktop.
HoloLens Unityアプリで、カメラへの許可がされているか確認する https://littlewing.hatenablog.com/entry/2018/12/21/191656
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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