void Start()
    {
        if (AndroidRuntimePermissions.CheckPermission("android.permission.RECORD_AUDIO") != AndroidRuntimePermissions.Permission.Granted)
        {
            AndroidRuntimePermissions.RequestPermission("android.permission.RECORD_AUDIO");
        }
        if (AndroidRuntimePermissions.CheckPermission("android.permission.WRITE_EXTERNAL_STORAGE") != AndroidRuntimePermissions.Permission.Granted)
        {
            AndroidRuntimePermissions.RequestPermission("android.permission.WRITE_EXTERNAL_STORAGE");
        }
        if (GameObject.FindGameObjectsWithTag("SceneThemeAudio").Length > 0)
        {
            sceneTheme = GameObject.FindGameObjectsWithTag("SceneThemeAudio")[0];
        }

        Bihou = GameObject.FindGameObjectWithTag("Bihou");

        dispatcher = Dispatcher.GetInstance();
        // for accessing audio
        utilsPlugin = UtilsPlugin.GetInstance();
        utilsPlugin.SetDebug(0);

        speechPlugin = SpeechPlugin.GetInstance();
        speechPlugin.SetDebug(0);
        speechPlugin.Init();

        // set the calling package this is optional
        // you can use this if your app is for children or kids
        speechPlugin.SetCallingPackage("com.mycoolcompany.mygame");

        AddSpeechPluginListener();
    }
Exemple #2
0
 //il faut mettre la demande de permission du GPS dans le Awake pour y avoir acces ensuite dans la scene, sinon il faudrait
 //redemarrer l application
 void Awake()
 {
     if (AndroidRuntimePermissions.CheckPermission("android.permission.ACCESS_FINE_LOCATION") != AndroidRuntimePermissions.Permission.Granted)
     {
         AndroidRuntimePermissions.RequestPermission("android.permission.ACCESS_FINE_LOCATION");
     }
 }
    // Use this for initialization
    void Start()
    {
        if (AndroidRuntimePermissions.CheckPermission("android.permission.RECORD_AUDIO") != AndroidRuntimePermissions.Permission.Granted)
        {
            AndroidRuntimePermissions.RequestPermission("android.permission.RECORD_AUDIO");
        }
        if (AndroidRuntimePermissions.CheckPermission("android.permission.ACCESS_FINE_LOCATION") != AndroidRuntimePermissions.Permission.Granted)
        {
            AndroidRuntimePermissions.RequestPermission("android.permission.ACCESS_FINE_LOCATION");
        }
        dispatcher = Dispatcher.GetInstance();
        // for accessing audio
        utilsPlugin = UtilsPlugin.GetInstance();
        utilsPlugin.SetDebug(0);

        speechPlugin = SpeechPlugin.GetInstance();
        speechPlugin.SetDebug(0);
        speechPlugin.Init();

        // set the calling package this is optional
        // you can use this if your app is for children or kids
        speechPlugin.SetCallingPackage("com.mycoolcompany.mygame");

        AddSpeechPluginListener();
    }
 void Awake()
 {
     // need to ask for GPS permision in Awake to have access to it later in the scene, otherwise need to reload the app
     if (AndroidRuntimePermissions.CheckPermission("android.permission.ACCESS_FINE_LOCATION") != AndroidRuntimePermissions.Permission.Granted)
     {
         AndroidRuntimePermissions.RequestPermission("android.permission.ACCESS_FINE_LOCATION");
     }
 }
Exemple #5
0
    private void Start()
    {
        _source      = GetComponent <AudioSource>();
        _source.loop = true;
        _source.outputAudioMixerGroup = micMixer;
        AndroidRuntimePermissions.Permission permission;

        do
        {
            permission = AndroidRuntimePermissions.CheckPermission("android.permission.RECORD_AUDIO");

            if (permission != AndroidRuntimePermissions.Permission.Granted)
            {
                permission = AndroidRuntimePermissions.RequestPermission("android.permission.RECORD_AUDIO");
            }
        } while (permission != AndroidRuntimePermissions.Permission.Granted);
    }
    //核查麦克风的权限
    public void CheckPermission()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidRuntimePermissions.Permission result = AndroidRuntimePermissions.CheckPermission("android.permission.RECORD_AUDIO");
        if (result == AndroidRuntimePermissions.Permission.Granted)
        {
            resultText.text = "核查--麦克风权限被--允许";
        }
        else if (result == AndroidRuntimePermissions.Permission.ShouldAsk)
        {
            resultText.text = "核查--麦克风权限被--未同意可询问";
        }
        else if (result == AndroidRuntimePermissions.Permission.Denied)
        {
            resultText.text = "核查--麦克风权限被--被拒绝到设置里开启";
        }
#elif UNITY_IOS && !UNITY_EDITOR
#else
#endif
    }
Exemple #7
0
    public void VerifyPermission()
    {
                #if UNITY_EDITOR
        SceneLoader.instance.LoadARScene();
                #endif
#if UNITY_IOS && !UNITY_EDITOR
        iOSCameraPermission.VerifyPermission(gameObject.name, "SampleCallback");
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidRuntimePermissions.Permission result = AndroidRuntimePermissions.CheckPermission("android.permission.CAMERA");

        switch (result)
        {
        case AndroidRuntimePermissions.Permission.Denied:
            _supportCanvasController.ShowWarningPanel();
            break;

        case AndroidRuntimePermissions.Permission.Granted:
            SceneLoader.instance.LoadARScene();
            break;

        case AndroidRuntimePermissions.Permission.ShouldAsk:
        {
            result = AndroidRuntimePermissions.RequestPermission("android.permission.CAMERA");

            if (result == AndroidRuntimePermissions.Permission.Granted)
            {
                SceneLoader.instance.LoadARScene();
            }
            else
            {
                _supportCanvasController.ShowWarningPanel();
            }

            break;
        }
        }
//       SaveManager.instance.SavePermissionRequest();
#endif
    }
 public void goToSearchState()
 {
             #if UNITY_IOS && !UNITY_EDITOR
     iOSCameraPermission.VerifyPermission(gameObject.name, "CameraPermissionCallback");
             #elif PLATFORM_ANDROID && !UNITY_EDITOR
     if (AndroidRuntimePermissions.CheckPermission("android.permission.CAMERA") == AndroidRuntimePermissions.Permission.Granted)
     {
         CameraPermissionCallback("true");
     }
     else
     {
         CameraPermissionCallback("false");
     }
             #else
     if (Application.HasUserAuthorization(UserAuthorization.WebCam))
     {
         CameraPermissionCallback("true");
     }
     else
     {
         CameraPermissionCallback("false");
     }
             #endif
 }