Exemple #1
0
 private IEnumerator RequestAndroidPermission(string permission)
 {
     if (!RuntimePermissionHelper.HasPermission(permission))
     {
         if (RuntimePermissionHelper.ShouldShowRequestPermissionRationale(permission))
         {
             RuntimePermissionHelper.RequestPermission(new string[] { permission });
         }
     }
     yield return(new WaitForSeconds(0.5f));
 }
Exemple #2
0
        IEnumerator Start()
        {
            exampleTitle.text = "NatCamWithOpenCVForUnity Example " + Application.version;

            versionInfo.text  = "NatCam " + GetNatCamVersion();
            versionInfo.text += " / " + OpenCVForUnity.CoreModule.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.UnityUtils.Utils.getVersion() + " (" + OpenCVForUnity.CoreModule.Core.VERSION + ")";
            versionInfo.text += " / UnityEditor " + Application.unityVersion;
            versionInfo.text += " / ";
#if UNITY_EDITOR
            versionInfo.text += "Editor";
#elif UNITY_STANDALONE_WIN
            versionInfo.text += "Windows";
#elif UNITY_STANDALONE_OSX
            versionInfo.text += "Mac OSX";
#elif UNITY_STANDALONE_LINUX
            versionInfo.text += "Linux";
#elif UNITY_ANDROID
            versionInfo.text += "Android";
#elif UNITY_IOS
            versionInfo.text += "iOS";
#elif UNITY_WSA
            versionInfo.text += "WSA";
#elif UNITY_WEBGL
            versionInfo.text += "WebGL";
#endif
            versionInfo.text += " ";
#if ENABLE_MONO
            versionInfo.text += "Mono";
#elif ENABLE_IL2CPP
            versionInfo.text += "IL2CPP";
#elif ENABLE_DOTNET
            versionInfo.text += ".NET";
#endif

            scrollRect.verticalNormalizedPosition = verticalNormalizedPosition;

            // Update GUI state
            cameraResolutionDropdown.value            = (int)cameraResolution;
            cameraFPSDropdown.value                   = (int)cameraFramerate;
            performImageProcessingEachTimeToggle.isOn = performImageProcessingEachTime;


#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
            RuntimePermissionHelper runtimePermissionHelper = GetComponent <RuntimePermissionHelper>();
            yield return(runtimePermissionHelper.hasUserAuthorizedCameraPermission());

            yield return(runtimePermissionHelper.hasUserAuthorizedExternalStorageWritePermission()); // It works only with Android devices.
#endif

            yield break;
        }