yasirkula / UnityAndroidRuntimePermissions

A native Unity plugin to handle runtime permissions on Android M+
MIT License
196 stars 29 forks source link

Latency of the Lock or Thread #1

Closed heitaoflower closed 3 years ago

heitaoflower commented 6 years ago

Hi handsome, I just try to utilize the plugin, frankly speaking it is very pratical, However the delay maybe cased by lock or something like that harm the experience, so Can u try to optimize it soon?

or offer some asynways.

Thanks .

yasirkula commented 6 years ago

I had actually implemented async functions just for the sake of reducing the delay but while testing them, I couldn't see a difference so I've concluded that this delay might be related to pausing the Unity activity and not the plugin itself. Thus, I've made those functions private.

You can change the visibility of AndroidRuntimePermissions.RequestPermissionAsync function to see if using it helps with the delay in your case. Here's an example code for it:

AndroidRuntimePermissions.RequestPermissionAsync( "android.permission.WRITE_EXTERNAL_STORAGE", ( permName, permValue ) => 
{
    if( permValue == AndroidRuntimePermissions.Permission.Granted )
        Debug.Log( "We have permission to access external storage!" );
    else
        Debug.Log( "Permission state: " + permValue );
} );

You can also try using this plugin to see if it also has the delay: https://github.com/Over17/UnityAndroidPermissions

heitaoflower commented 6 years ago

Of course, I will try it next week if there is any progress to sync to you ,

Thx agin, my friend.